最近使用nvm 安装node的时候
发现安装的版本是 8.12.0已经以后的版本的时候输出为:
G:\VsCodeProjects>nvm install 8.12.0
Downloading node.js version 8.12.0 (64-bit)...
Complete
Creating C:\Users\***\AppData\Roaming\nvm\temp
Downloading npm version 6.4.1... Complete
Installing npm v6.4.1...
Installation complete. If you want to use this version, type
nvm use 8.12.0
但是执行nvm use 8.12.0之后执行npm
G:\VsCodeProjects>npm
'npm' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
目前还没有找到原因,
原因是使用了1.1.6版本,是用1.1.7版本问题就消失了,(╯‵□′)╯︵┻━┻
解决方式是:
去安装的文件下将其他版本node中的npm文件即
node_modules、npm、npm.cmd
直接拷贝到没有的文件夹下,然后升级npm
npm install npm@latest -g
升级npm
执行之后可能会出现这样的错误
npm ERR! path D:\nodejs\npm.cmd
npm ERR! code EEXIST
npm ERR! Refusing to delete D:\nodejs\npm.cmd: is outside D:\nodejs\node_modules\npm and not a link
npm ERR! File exists: D:\nodejs\npm.cmd
npm ERR! Move it away, and try again.
或者这样的警告
npm WARN npm npm does not support Node.js v10.15.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, 9.
npm WARN npm You can find the latest version at https://nodejs.org/
npm WARN npm npm does not support Node.js v10.15.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, 9.
npm WARN npm You can find the latest version at https://nodejs.org/
可以先安装cnpm
npm i cnpm -g
然后通过cnpm升级npm
cnpm i npm@6.4.1 -g
应该就可以用了