首页 > 解决方案 > 如何修复 Windows 上的“npm 不支持 Node.js v11.14.0 错误”?

问题描述

我正在配置我的 react-native 环境。我正在尝试按照此处Facebook 的 Github 文档中的描述运行 react-native 命令行

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

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

这是代码

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 命令行界面。当我尝试调用接口时收到错误消息。

标签: node.jsnpmcommand-linenpm-install

解决方案


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

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


推荐阅读