Unable to resolve module crypto in Node backend
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- javascript, node.js, react-native
- 领域
- backend, mobile-dev
调研方向
首先,使用 Node 16.15.1 在提供的 React Native 应用程序中复现 Metro 解析失败。检查 jsonwebtoken/verify.js 中的 crypto 导入,以及报告中显示的 Metro ModuleResolution.js 堆栈。确认此 Node 后端用法是否受支持,并记录已确认的解决方案或限制,即视为完成。
由索引模型根据 Issue 内容生成。
描述
Description
I'm trying to use the sign function in my NodeJS backend of my React Native application.
Reproduction
I have the following code:

and it's throwing me the following error:
`Error: Unable to resolve module crypto from /Users/{username}/Documents/Projets/app/server/node_modules/jsonwebtoken/verify.js: crypto could not be found within the project or in these directories:
server/node_modules/jsonwebtoken/node_modules
server/node_modules
node_modules
7 | const PS_SUPPORTED = require('./lib/psSupported');
8 | const jws = require('jws');
9 | const {KeyObject, createSecretKey, createPublicKey} = require("crypto");
| ^
10 |
11 | const PUB_KEY_ALGS = ['RS256', 'RS384', 'RS512'];
12 | const EC_KEY_ALGS = ['ES256', 'ES384', 'ES512'];
at ModuleResolver.resolveDependency (/Users/{username}/Documents/Projets/app/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:162:15)
at DependencyGraph.resolveDependency (/Users/{username}/Documents/Projets/app/node_modules/metro/src/node-haste/DependencyGraph.js:260:43)
at Object.resolve (/Users/{username}/Documents/Projets/app/node_modules/metro/src/lib/transformHelpers.js:177:21)
at Graph._resolveDependencies (/Users/{username}/Documents/Projets/app/node_modules/metro/src/DeltaBundler/Graph.js:432:35)
at Graph._processModule (/Users/{username}/Documents/Projets/app/node_modules/metro/src/DeltaBundler/Graph.js:218:38)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Graph._addDependency (/Users/{username}/Documents/Projets/app/node_modules/metro/src/DeltaBundler/Graph.js:314:20)
at async Promise.all (index 0)
at async Graph._processModule (/Users/{username}/Documents/Projets/app/node_modules/metro/src/DeltaBundler/Graph.js:263:5)`
Environment
Please provide the following:
My version of Node is 16.15.1
- 主要语言
- JavaScript
- 星标
- 18.2k
- 派生
- 1.3k
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
auth0/node-jsonwebtoken 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
auth0/node-jsonwebtoken#1042 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 84/100
auth0/node-jsonwebtoken#1000 · 2 条评论 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 65/100
auth0/node-jsonwebtoken#1046 ·
-
难度 5/5 一周以上 新手友好度 10/100
auth0/node-jsonwebtoken#1034 ·
-
难度 3/5 1-2 天 新手友好度 48/100
auth0/node-jsonwebtoken#1032 ·
查看 auth0/node-jsonwebtoken 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
-
area-deployment area-integrations triage:bot-seen
难度 2/5 半天 新手友好度 86/100
-
Issue-Bug
难度 2/5 1-3 小时 新手友好度 68/100
sugarlabs/musicblocks#8924 ·
-
难度 1/5 1 小时以内 新手友好度 90/100
ArduPilot/ardupilot_wiki#8088 ·
-
[BUG] createTool tools cannot be registered with Mastra when exactOptionalPropertyTypes is enabled 未关闭customer-eng status: needs triage
难度 2/5 1-3 小时 新手友好度 84/100
