无法使用npm安装react-navigation软件包

时间:2019-01-10 19:06:29

标签: javascript reactjs react-native react-navigation expo

我正在使用Expo构建一个应用程序。我想使用react-navigation能够在屏幕之间导航。

但是我在安装软件包时遇到了麻烦。实际上,我要安装的每个软件包都存在此问题...

通过运行安装脚本:

npm install-保存反应导航

我收到这些警告,但无法在我的项目中导入包:

npm WARN expo-google-sign-in@2.0.0 requires a peer of react-native@^0.55.4 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-reanimated@1.0.0-alpha.11 requires a peer of react@16.0.0-alpha.6 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-reanimated@1.0.0-alpha.11 requires a peer of react-native@^0.44.1 but none is installed. You must install peer dependencies yourself.
npm WARN url-loader@1.1.2 requires a peer of webpack@^3.0.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
 终端错误ouptu是:

While trying to resolve module `react-navigation` from file 
`/app/App.js`, the package `/app/node_modules/reactnavigation/package.json` 
was successfully found. 
However, this package itself specifies a `main` module field that could not be resolved 
(`/app/node_modules/react-navigation/src/react-navigation.js`. Indeed, none of these files exist:
[13:58:26] 
[13:58:26]   * `/app/node_modules/react-navigation/src/react-navigation.js(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)`
[13:58:26]   * `/app/node_modules/react-navigation/src/react-navigation.js/index(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)`

每次尝试安装软件包时都会遇到此问题。我没有找到适合我的解决方案。

1 个答案:

答案 0 :(得分:0)

如果仍然存在该问题,请尝试使用react-navigation 2.0。最新版本并不总是最稳定的版本