尝试运行一个react-native项目,该项目具有x-resources包作为依赖项,使用yarn安装了依赖项,但当我尝试运行该项目时,我在运行时得到此错误
bundling failed: Error: While trying to resolve module `x-resources` from file `/***/index.js`, the package `/***/node_modules/x-resources/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/***/node_modules/x-resources/dist/index.js`. Indeed, none of these files exist:
* /***/node_modules/x-resources/dist/index.js(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
* /***/node_modules/x-resources/dist/index.js/index(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
at ResolutionRequest.resolveDependency (/***/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:65:15)
at DependencyGraph.resolveDependency (/***/node_modules/metro/src/node-haste/DependencyGraph.js:282:16)
at Object.resolve (/***/node_modules/metro/src/lib/transformHelpers.js:267:42)
at /***/node_modules/metro/src/DeltaBundler/traverseDependencies.js:426:31
at Array.map (<anonymous>)
at resolveDependencies (/***/node_modules/metro/src/DeltaBundler/traverseDependencies.js:423:18)
at /***/node_modules/metro/src/DeltaBundler/traverseDependencies.js:275:33
at Generator.next (<anonymous>)
at asyncGeneratorStep (/***/node_modules/metro/src/DeltaBundler/traverseDependencies.js:87:24)
at _next (/***/node_modules/metro/src/DeltaBundler/traverseDependencies.js:107:9)
在这个包里没有**/dist**文件夹,我不明白为什么它要找index。js在里面,我不知道这是一个地铁相关的问题,或者它是特定于这个包,我已经尝试关闭运行js服务器多次,但没有运气。
- React:16.9。0
- react-native:0.61.4
- x资源:1.1.2
- axios:0.19。0
1条答案
按热度按时间vmdwslir1#
这可能是由于不匹配的
node_modules
和Pods
。我在yarn workspaces项目中更新deps时看到了类似的错误,我通过清除我的依赖项,* 所有 * 我的依赖项,包括子包中的依赖项来解决这个问题。删除锁文件并不是严格要求的,因为我们只想确保node_modules处于原始状态。