npm安装上的React Navigation Error

时间:2018-01-11 20:33:12

标签: android node.js react-native react-navigation

我正在尝试使用反应导航创建一个新的反应原生应用。

我做了以下事情:

1。)create-react-native-app myAppName

2。)cd myAppName /

3。)npm install --save react-navigation

4.。)期望成功安装react-navigation,但我得到:

C:\Users\Maima\Documents\GitHub\React\test>npm install --save react-navigation
npm WARN rm not removing C:\Users\Maima\Documents\GitHub\React\test\node_modules
\.bin\jest.cmd as it wasn't installed by C:\Users\Maima\Documents\GitHub\React\t
est\node_modules\jest
npm WARN rm not removing C:\Users\Maima\Documents\GitHub\React\test\node_modules
\.bin\jest as it wasn't installed by C:\Users\Maima\Documents\GitHub\React\test\
node_modules\jest
npm WARN rm not removing C:\Users\Maima\Documents\GitHub\React\test\node_modules
\.bin\rimraf.cmd as it wasn't installed by C:\Users\Maima\Documents\GitHub\React
\test\node_modules\rimraf
npm WARN rm not removing C:\Users\Maima\Documents\GitHub\React\test\node_modules
\.bin\rimraf as it wasn't installed by C:\Users\Maima\Documents\GitHub\React\tes
t\node_modules\rimraf
npm WARN rm not removing C:\Users\Maima\Documents\GitHub\React\test\node_modules
\.bin\uuid.cmd as it wasn't installed by C:\Users\Maima\Documents\GitHub\React\t
est\node_modules\uuid
npm WARN rm not removing C:\Users\Maima\Documents\GitHub\React\test\node_modules
\.bin\uuid as it wasn't installed by C:\Users\Maima\Documents\GitHub\React\test\
node_modules\uuid
npm WARN rm not removing C:\Users\Maima\Documents\GitHub\React\test\node_modules
\.bin\semver.cmd as it wasn't installed by C:\Users\Maima\Documents\GitHub\React
\test\node_modules\semver
npm WARN rm not removing C:\Users\Maima\Documents\GitHub\React\test\node_modules
\.bin\semver as it wasn't installed by C:\Users\Maima\Documents\GitHub\React\tes
t\node_modules\semver
npm notice created a lockfile as package-lock.json. You should commit this file.

npm WARN react-navigation@1.0.0-beta.23 requires a peer of react@* but none is i
nstalled. You must install peer dependencies yourself.
npm WARN react-navigation@1.0.0-beta.23 requires a peer of react-native@* but no
ne is installed. You must install peer dependencies yourself.
npm WARN react-native-tab-view@0.0.74 requires a peer of react@* but none is ins
talled. You must install peer dependencies yourself.
npm WARN react-native-tab-view@0.0.74 requires a peer of react-native@* but none
 is installed. You must install peer dependencies yourself.
npm WARN react-native-drawer-layout-polyfill@1.3.2 requires a peer of react-nati
ve@* but none is installed. You must install peer dependencies yourself.
npm WARN react-native-drawer-layout@1.3.2 requires a peer of react@* but none is
 installed. You must install peer dependencies yourself.
npm WARN react-native-drawer-layout@1.3.2 requires a peer of react-native@* but
none is installed. You must install peer dependencies yourself.

+ react-navigation@1.0.0-beta.23
added 8 packages, removed 973 packages and updated 20 packages in 259.667s

请帮助,不能开始我的React Native App。

6 个答案:

答案 0 :(得分:4)

可以通过再次运行npm install命令并重新安装npm install --save react-navigation命令来解决此问题。

答案 1 :(得分:1)

我不能发表评论,因为我没有积分,所以暂时回答一下该信息:

在Windows上运行Expo时遇到了类似的问题。解决我不得不关闭XDE并重新安装。

如果还不够,请删除“node_modules”文件夹并运行“npm install”。

答案 2 :(得分:1)

它们不是错误,只是警告告诉您导航依赖的某些对等依赖项尚未安装。根据您的命令,您需要运行npm installyarn install来安装所有软件包。使用create-react-native应用创建应用会为您提供一个包列表,但您必须使用npm install实际安装它们。如果发生了一些时髦的事情,请执行@vbandrade建议的内容并填充您的node_modules和package.lock,然后重新执行npm install

答案 3 :(得分:0)

当我尝试运行npm install --save react-navigation时出现了相同的错误。原来我需要在npm install之前运行npm install --save react-navigation

答案 4 :(得分:0)

按照步骤操作,但 npm install 出错。我也在使用 Expo(如@vbandrade 所述),并且也存在问题。首先,我认为 react-navigation 正在发生很大变化。在尝试了很多之后(在已接受的答案中应用解决方案之前),我多次安装了 react-navigation 及其依赖项,并且在我第一次运行时一次运行;

npm install react-navigation

然后

npm install @react-navigation/native

(这对我来说没有太大意义,因为它会通过 react-navigation 自动安装)。然后我跑了;

npm install react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view

用于安装依赖项并且它起作用了。老实说,我不明白它是如何工作的。因此,为了学习起见,我安装了该项目并使用 expo 重新安装了它,之后没有任何效果。所以我应用了@vbandrade 的答案,但在我运行 npm install 后它给出了更多错误。

为了摆脱这些错误,我找到了另一个解决方案(来自 stackoverflow)。这是解决方案。首先删除 node_modules 文件夹和 package-lock.json 文件并关闭您的编辑器或任何其他打开项目的文件(因为如果项目打开,节点不会安装某些包) .

那么,

首先运行这个命令;

npm cache clean --force

那么,

npm install

然后;

npm install react-navigation

最后安装依赖项;

npm install react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view

运行你的项目;

如果使用expo;

expo start 

错误现在必须消失。

答案 5 :(得分:0)

如果您正在运行 expo 服务器,请停止服务器并继续 npm install --save react-navigation 。它对我有用。