我正在配置我的本机环境。我试图按照Facebook的Github文档here
中的描述运行react-native命令行当我返回C:\WINDOWS\system32>node -v
v11.14.
时,我已经安装了最新版本的node.js。
最新版本的node.js中包含下载的npm。但是,它只有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命令行界面。尝试调用该接口时出现错误。
答案 0 :(得分:0)
您正在使用npm的旧版本。请升级到最新版本。
答案 1 :(得分:0)
简单的解决方案是升级您的npm版本,第二个选项是降级您的节点版本。
从此处下载旧节点版本
https://nodejs.org/en/download/releases/
如何更新npm?
npm install -g npm
请注意,此命令将删除您当前的npm版本。 如果在Mac上,请确保使用sudo npm install -g npm。
您还可以通过执行npm更新所有过时的本地软件包 通过执行npm update来更新不带任何参数的全局包 -g。
有时,npm的版本会不断更新,以使当前 版本不能正确安装与您具有的版本 已安装。 (考虑一下,如果更新中存在错误, 命令。)在这种情况下,您可以这样做
答案 2 :(得分:0)
npm install -g npm-windows-upgrade
npm-windows-upgrade
答案 3 :(得分:0)
我从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-
debug.log
答案 4 :(得分:0)
我在使用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
来安装项目包。
答案 5 :(得分:0)
最新版本存在相同的问题。 删除所有NodeJS安装。 目前,npm支持节点js版本6、8、9、10、11。
转到this版(或更旧的版本)下载msi文件,然后进行npm安装。
答案 6 :(得分:0)
安装当前的NodeJS LTS之后,我仍然得到
npm does not support Node.js {version}
。
我删除了C:\Users\{user}\AppData\Roaming\npm\
中的所有文件,并且可以正常工作。