【问题标题】:React Navigation Error on npm install在 npm install 上反应导航错误
【发布时间】:2018-01-11 20:33:12
【问题描述】:

我正在尝试使用反应导航创建一个新的反应本机应用程序。

我做了以下事情:

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

请帮忙,不能 npm 启动我的 React Native 应用程序。

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

    • 这真的很有帮助,它对我有用,简单易行!!!
    • 是的,这很有效,但它真的很奇怪。只要继续尝试,它就会在某些时候完成......
    • 感谢这对 react native cli 起作用
    【解决方案2】:

    我不能评论,因为我没有要点,所以这里是暂时的答案与信息:

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

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

    【讨论】:

      【解决方案3】:

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

      【讨论】:

        【解决方案4】:

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

        【讨论】:

          【解决方案5】:

          按照步骤操作,但出现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 start 
          

          现在必须消除错误。

          【讨论】:

            【解决方案6】:

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

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 2022-01-21
              • 2018-11-01
              • 1970-01-01
              • 2019-10-08
              • 2020-08-29
              • 2022-06-20
              • 1970-01-01
              • 1970-01-01
              相关资源
              最近更新 更多