【问题标题】:React Navigation npm install ERR fresh Expo Init @react-navigation/native@3.1.4React Navigation npm install ERR fresh Expo Init @react-navigation/native@3.1.4
【发布时间】:2019-07-02 18:34:42
【问题描述】:

React Native Expo 用户!

我在使用 react-navigation(空白和标签)的 expo init 上遇到错误:

npm ERR! 404  '@react-navigation/native@3.1.4' is not in the npm registry.

几个月来我一直在使用 Expo 进行 React Native 开发,并且在学习和解决错误的过程中取得了巨大的成功!

我放了个假,回来开始一个新项目,用 react-navigation@^3.0.0 碰壁 - 我尝试了很多解决方案,但没有工作。

我正在使用 expo 和 npm 启动一个新项目,选项卡和空白模板都有 react-navigation npm install 问题:

expo init
? Choose a template: expo-template-tabs
? Choose which workflow to use: managed
✔ Please enter a few initial configuration values.
  Read more: https://docs.expo.io/versions/latest/workflow/configuration · 100% completed
? Yarn v1.13.0 found. Use Yarn to install dependencies? No
[08:18:30] Extracting project files...
[08:18:31] Customizing project...
[08:18:31] Initialized a git repository.
[08:18:31] Installing dependencies...
npm WARN deprecated kleur@2.0.2: Please upgrade to kleur@3 or migrate to 'ansi-colors' if you prefer the old syntax. Visit <https://github.com/lukeed/kleur/releases/tag/v3.0.0\> for migration path(s).
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@react-navigation%2fnative - Not Found
npm ERR! 404
npm ERR! 404  '@react-navigation/native@3.1.4' is not in the npm registry.
npm ERR! 404 Your package name is not valid, because
npm ERR! 404  1. name can only contain URL-friendly characters
npm ERR! 404 It was specified as a dependency of 'react-navigation'
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/ddcjosiahl/.npm/_logs/2019-02-08T13_18_47_333Z-debug.log
[08:18:47] Process exited with non-zero code: 1
[08:18:47] Set EXPO_DEBUG=true in your env to view the stack trace.

我正在尝试没有运气的选项:

  • 已清除 NPM 缓存

  • 试纱

  • 再次安装expo cli

  • npm install --save react-navigation ... react-native、native等

    npm install --save react-navigation npm 错误!代码 E404 npm 错误! 404 未找到:@react-navigation/native@3.1.4

    • 注意:昨天我花了一整天的时间试图让新项目开始工作。我确实设法通过安装不同版本的 react-native 来通过它,并且无法复制......然后导致版本不匹配并且应用程序无法加载:*

****RNGestureHandlerButton:**** enter image description here

为什么 react-navigation@^3.0.0 需要 native@3.1.4 以及如何解决?

谢谢!

【问题讨论】:

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


    【解决方案1】:

    我不清楚您的确切问题是什么。因此,我假设您无法将 React-navigation 与 expo 一起使用。

    尝试在整个过程中使用 yarn 而不是 npm。

    当 expo 要求创建一个新项目然后安装 react-navigation 使用时使用 yarn-

    纱线添加反应导航

    我昨天使用了导航,它对我来说非常有用。

    【讨论】:

    • 我已经使用 npm 好几个月了。 * 我从运行 yarn 得到同样的结果在“npm”注册表中找不到“react-navigation@^3.0.9”所需的包“@react-navigation/native@3.1.4”。
    • yarn add react-navigation 错误在“npm”注册表中找不到“react-navigation”所需的包“@react-navigation/native@3.1.4”。
    • 尝试expo start --clear,然后重新安装 react-navigation。
    • 我现在正在使用纱线 - 竖起大拇指!虽然仍然存在同样的问题在“npm”注册表中找不到“react-navigation”所需的包“@react-navigation/native@3.1.4”。 expo clear 和我的注册表没有运气=registry.npmjs.org
    【解决方案2】:

    这很奇怪,因为我刚刚尝试过,它很好地获取了所有依赖项的 react-navigation。实际上,如果您直接在浏览器中加载 https://registry.npmjs.org/@react-navigation%2fnative url,您应该会看到相应的 JSON 模式。如果它为您提供 404,您可能需要对 DNS 解析器进行故障排除。

    【讨论】:

    • 我在辅助 macOS 环境中取得了成功。问题与我的全局文件或 https 注册表隔离.. 不完全确定.. 奇怪
    【解决方案3】:

    我在从 expo v31 升级到 v32 时遇到了同样的问题。尝试了您所做的所有事情,但没有运气。最后,使用npm install https://github.com/react-navigation/react-navigation-native 从 github 安装解决了我的问题。然后我分别安装了 react-navigation 包,然后是我的项目所需的所有其他模块。

    【讨论】:

    • 虽然您确实可以从 github(或任何其他直接 url)安装软件包,但这不是解决此问题的方法,因为您牺牲了对所有更新和错误修复的访问(其中一点包管理器)。
    • 是的,你是对的。我只是想有任何可行的解决方案。对 npm 注册表缺乏了解是我的错。我实际上尝试了@Josiah 建议的解决方案,它奏效了。我只是无法在他的帖子中添加评论,因为我在 stackoverflow 中没有足够的“声誉”。我仍然想知道为什么有些人有这个问题而其他人没有?以及为什么该特定软件包有问题。我以前从来没有遇到过这个问题。另一件事是,只有当我将注册表更改为registry.npmjs.COM 时,它才起作用。不幸的是,我仍然不明白。
    【解决方案4】:

    通过编辑根 .npmrc 文件来解决,确认我有: 注册表=https://registry.npmjs.org/

    我的问题与“_auth="有关。

    npm 和 yarn 现在都可以与我得到的 react-navigation 和 404 一起使用。 谢谢@Munishkin 和@Atin Singh

    【讨论】:

    • 我个人为RN项目添加了一个本地的.npmrc,注册表指向:registry.npmjs.COM就像@Munishkin说的那样
    猜你喜欢
    • 2020-11-07
    • 2017-10-24
    • 1970-01-01
    • 1970-01-01
    • 2019-10-16
    • 1970-01-01
    • 2021-10-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多