繁体   English   中英

如何修复 Windows 上的“npm 不支持 Node.js v11.14.0 错误”?

[英]How to fix 'npm does not support Node.js v11.14.0 error' on Windows?

我正在配置我的本机环境。 我正在尝试运行这里的Facebook 的 Github 文档中描述的 react-native 命令行

当我输入C:\\WINDOWS\\system32>node -v v11.14.时,我已经安装了最新版本的v11.14. 被退回。

下载的 npm 包含在最新版本的 node.js 中。 然而,它只是 5.5.1。 当我输入C:\\WINDOWS\\system32>npm -v结果是5.5.1

  • 我尝试卸载并重新安装
  • 我尝试下载 node.js 的 LTS 版本
  • 我已经尝试升级 node.js 和 npm
  • 这适用于 Windows 10
  • 这是从管理命令提示符和管理电源外壳运行

这是代码

C:\WINDOWS\system32>npm install -g react-native-cli
npm WARN npm npm does not support Node.js v10.15.3
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8.
npm WARN npm You can find the latest version at https://nodejs.org/
npm ERR! Cannot read property 'startsWith' of null

npm ERR! A complete log of this run can be found in:

当我尝试使用npm cache clean -f清理缓存时,结果是

C:\WINDOWS\system32>npm cache clean -f
npm WARN npm npm does not support Node.js v10.15.3
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8.
npm WARN npm You can find the latest version at https://nodejs.org/
npm WARN using --force I sure hope you know what you are doing.

编辑以下代码是一些建议的解决方案的结果

C:\WINDOWS\system32>npm install -g npm
npm WARN npm npm does not support Node.js v11.14.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8.
npm WARN npm You can find the latest version at https://nodejs.org/
npm ERR! Cannot read property 'startsWith' of null

npm ERR! A complete log of this run can be found in:
C:\WINDOWS\system32>npm install -g npm-windows-upgrade
npm WARN npm npm does not support Node.js v11.14.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8.
npm WARN npm You can find the latest version at https://nodejs.org/
npm ERR! Cannot read property 'startsWith' of null

npm ERR! A complete log of this run can be found in:
C:\WINDOWS\system32>npm install -g npm-windows-upgrade
npm WARN npm npm does not support Node.js v11.14.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8.
npm WARN npm You can find the latest version at https://nodejs.org/
npm ERR! Cannot read property 'startsWith' of null

npm ERR! A complete log of this run can be found in:

我希望打开 npm 命令行界面。 当我尝试调用接口时收到错误。

npm install -g npm-windows-upgrade
npm-windows-upgrade

我从 C:\\Users{name}\\AppData\\Roaming 中删除了节点和 npm。 然后我重新安装了旧版本的 node.js v10.15.3 和 npm 6.4.1。

这带来了一个不同的错误,所以我将关闭这个问题......

C:\>npm install -g expo-cli
npm ERR! Cannot read property 'startsWith' of null

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\dnort\AppData\Roaming\npm-cache\_logs\2019-04-15T06_32_09_154Z- 

调试日志

安装当前的 NodeJS LTS 后,我仍然得到npm does not support Node.js {version}

我删除了C:\\Users\\{user}\\AppData\\Roaming\\npm\\所有文件,它可以工作。

您使用的是旧版本的 npm。 请升级到最新版本。

简单的解决方案是升级您的 npm 版本或第二个选项是降级您的节点版本。

从这里下载较旧的节点版本

https://nodejs.org/en/download/releases/

我如何更新 npm?

npm install -g npm

请注意,此命令将删除您当前版本的 npm。 如果在 Mac 上,请确保使用 sudo npm install -g npm。

您还可以通过执行不带任何参数的 npm update 来更新所有过时的本地包,或者通过执行 npm update -g 来更新全局包。

有时,npm 的版本会进步,以至于当前版本无法与您已经安装的版本一起正确安装。 (考虑一下,如果更新命令中存在错误。)在这些情况下,您可以这样做

我在使用 npm 时遇到了同样的问题,所以我在考虑 npm 的替代方案。 而且,你可以试试纱线。

首先,前往https://nodejs.org/en/下载 LTS 版本的 nodejs。

其次,到https://yarnpkg.com下载稳定版本的 msi 文件。

注意 nodejs 和 yarn 当前版本分别是 10.16.0 LTS 和 1.17.3。 安装后,您可以使用yarn install而不是npm install来安装您的项目包。

最新版本也有同样的问题。 删除所有 NodeJS 安装。 目前 npm 支持 node js 版本 6、8、9、10、11。

转到版本(或更旧)下载 msi 文件,然后执行 npm install。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM