node.js - 如何修复 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
- 我已尝试卸载并重新安装
- 我尝试下载 node.js 的 LTS 版本
- 我尝试升级 node.js 和 npm
- 这适用于 Windows 10
- 这是从管理命令提示符和管理电源 shell 运行的
这是代码
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 命令行界面。当我尝试调用接口时收到错误消息。
解决方案
安装当前的 NodeJS LTS 后,我仍然得到
npm does not support Node.js {version}
.
我删除了所有文件C:\Users\{user}\AppData\Roaming\npm\
,它可以工作。
推荐阅读
- c# - linq to sql 事务异常
- arrays - 将字节从 PDF 文件转换为图像的问题
- python - 关于最接近点的像素的pytorch(numpy)计算
- kubernetes - cgroup 中的 CPU 负载度量单位是什么(CPU 使用率和 CPU 负载之间的差异)?
- javascript - HTML / Javascript - 指定要使用的本地文件,而不是使用输入文件字段上传
- jmeter - 即使文档确实包含预期的文本,响应断言也会失败
- javascript - 获取childNodes的内容
- mysql - SQL 选择行并分组为数组项
- javascript - 异常情况下的 XMLHTTPRequest 状态 0
- complex-event-processing - 使用 NEsper 读取日志文件以进行报告