我有一个,它不能同时构建安卓和iOS应用程序(XCode,Android,物理设备)。在package.json内部,我没有改变任何东西。
该错误是由@react-node_module中的一个文件(Node_module)引起的:
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useRegisterNavigator;
var _nonSecure = require("nanoid/non-secure"); 这是iOS模拟器中出现的错误消息:
Unable to resolve module ../../../../nanoid/non-secure/index.cjs from /Users/username/Code/my-app/node_modules/@react-navigation/core/lib/commonjs/useRegisterNavigator.js:
None of these files exist:
* node_modules/nanoid/non-secure/index.cjs(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
* node_modules/nanoid/non-secure/index.cjs/index(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
> 1 | "use strict";
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true为什么我会得到这个错误?,奈米文件夹和反应导航文件夹存在于node_modules中。
我尝试过一些不起作用的东西:
metro.config.js文件中添加了一个解析器,查找“cjs”源扩展名:
resolver:{ sourceExts:...sourceExts,'cjs',}pod install重新安装豆荚。pod cache clean --all清理荚缓存npx react-native start --reset-cacherm -rf ~/Library/Caches/CocoaPods; rm -rf Podsl; rm -rf ~/Library/Developer/Xcode/DerivedData/*; pod deintegrate; pod setup; pod install;https://stackoverflow.com/questions/71562148
复制相似问题