【发布时间】:2019-06-27 01:44:02
【问题描述】:
这是我的 package.json
{
"name": "Locals",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"@babel/runtime": "^7.3.1",
"react": "16.6.3",
"react-native": "0.58.3",
"react-native-elements": "^1.0.0",
"react-native-vector-icons": "^6.2.0"
},
"devDependencies": {
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "24.0.0",
"jest": "24.0.0",
"metro-react-native-babel-preset": "0.51.1",
"react-test-renderer": "16.6.3"
},
"jest": {
"preset": "react-native"
}
}
我得到以下失败日志:
加载依赖图,完成。错误:捆绑失败:错误:不能 查找模块“NativeModules” 在 Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15) 在 Function.Module._load (internal/modules/cjs/loader.js:507:25) 在 Module.require (internal/modules/cjs/loader.js:637:17) 在需要(内部/模块/cjs/helpers.js:20:18) 在 Object.get NativeModules [as NativeModules] (/Users/vb05mj/Developer/personal/small-town/Locals/node_modules/react-native/Libraries/react-native/react-native-implementation.js:313:12) 在 Object.get [as NativeModules] (/Users/vb05mj/Developer/personal/small-town/Locals/node_modules/react-native-vector-icons/dist/lib/react-native.js:1:344) 在对象。 (/Users/vb05mj/Developer/personal/small-town/Locals/node_modules/react-native-vector-icons/dist/lib/ensure-native-module-available.js:1:238) 在 Module._compile (internal/modules/cjs/loader.js:689:30)
【问题讨论】:
-
您必须将版本保存在 package.json 中。您是否运行了
npm install react-native-vector-icons --save,然后将其作为本机依赖项与react-native link react-native-vector-icons链接 -
是的,没有帮助。
-
好吧,问题似乎出在 react-native-vector-icons 上。我的下一步是
react-native unlink react-native-vector-icons && npm remove react-native-vector-icons并尝试重新安装(确保我使用了npm install react-native-vector-icons --save和react-native link react-native-vector-icons
标签: reactjs react-native