【问题标题】:installing react-navigation with npm gives an error使用 npm 安装 react-navigation 会出错
【发布时间】:2020-10-01 17:40:25
【问题描述】:

我知道已经有关于这个的问题,但他们没有工作,其中大部分是用于 create-react-native-app 但我正在使用 expo。

我运行npm install react-navigation,它给了我这个错误:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: file-uri-to-path@1.0.0 (node_modules\file-uri-to-path):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename 'C:\Users\yaelp\Downloads\meals-cat\node_modules\file-uri-to-path' -> 'C:\Users\yaelp\Downloads\meals-cat\node_modules\.file-uri-to-path.DELETE'

npm ERR! code ENOENT
npm ERR! syscall rename
npm ERR! path C:\Users\yaelp\Downloads\meals-cat\node_modules\hoist-non-react-statics
npm ERR! dest C:\Users\yaelp\Downloads\meals-cat\node_modules\.hoist-non-react-statics.DELETE
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\yaelp\Downloads\meals-cat\node_modules\hoist-non-react-statics' -> 'C:\Users\yaelp\Downloads\meals-cat\node_modules\.hoist-non-react-statics.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\yaelp\AppData\Roaming\npm-cache\_logs\2020-10-01T17_02_25_868Z-debug.log

【问题讨论】:

    标签: react-native npm react-native-navigation


    【解决方案1】:

    尝试安装所有依赖项(来自 react-navigation 的文档)。

    运行:

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

    【讨论】:

      【解决方案2】:

      我希望您现在解决了您的问题(自您发布问题以来已经过去了一个多月)。对于那些可能得到它的人(就像我一样),这里有一些可能的解决方案:

      1. 使用 yarn 安装 react-navigation: 在官方react-navigation docs中有一个yarn install 命令:

        yarn add react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view

      2. 尝试删除 package-lock.json 文件,然后再次尝试使用 npm 安装 react-navigation

      3. 杀死你的应用,然后尝试安装 react-navigation,

      4. 删除你的 node_modules 并再次执行npm i

      5. 尝试卸载 node、npm 和它的所有东西(当然之后重新安装所有东西)。

      我从github issue 获得了这些解决方案。我希望他们中的一个会有所帮助。

      【讨论】:

        【解决方案3】:

        尝试使用expo install react-navigation,就像您使用 expo 一样。

        如果你需要使用npm,试试:

        npm install react-navigation --force

        【讨论】:

          【解决方案4】:

          尝试运行 npm install,然后 npm install @react-navigation/native from reactnavigation

          【讨论】:

            猜你喜欢
            • 2020-11-07
            • 2021-07-15
            • 2021-10-09
            • 2023-03-21
            • 1970-01-01
            • 1970-01-01
            • 2019-10-01
            • 2019-10-16
            • 2016-01-19
            相关资源
            最近更新 更多