Use nvm problem after managing multiple versions of nodeJS the successful installation nodeJs use npm being given

After using nvm installation nodeJS, node -v command can be used normally, but npm command has been reported, "is not an internal command npm" error, the following solution after thorough research:

Build steps:

(1) download nvm https://github.com/coreybutler/nvm-windows/releases, download, unzip and install from a selected version.

(2) the installation procedure:

Installation address is set nvm of: "C: \ softtool \ nvm", node address to: "C: \ softtool \ nodejs". It should be noted that the address can not be set to "C: \ Program Files", the installation path without spaces or node can not be used (online said, not tested).

Administrator, open a cmd; perform node management operations.

At the command line, type nvm nvm see if the installation was successful: appear as shown below nvm version installation was successful.

(3) In nvm installation directory, to find setting.txt with Notepad add the following two lines:

node_mirror: https://npm.taobao.org/mirrors/node/

npm_mirror: https://npm.taobao.org/mirrors/npm/

After the addition is shown below:

Note: Installation nodejs version you want, and must be npm nodejs are successful, because sometimes npm not download or nodejs successful, unsuccessful for many reasons, here recommend a clean uninstall nodejs already installed, not previously installed on nodejs do not care. View downloadable by nvm list available commands nodejs version information needed to download the corresponding version, LTS column represents the stable version.

(4)通过命令nvm install 版本号,下载即可,这里下载的是10.15.3版本,目前发现 8.11以上版本的node版本对应的npm都没法自动安装,需要自己到npm官网( https://npm.taobao.org/mirrors/npm/)下载手动安装对应的npm版本。

如上图所示表示安装成功了,npm v6.4.1也安装成功了,继续检验是否真的成功,进入nvm目录查看:

 

 进入v10.15.3目录:

 

如上图所示,可以实质上看到npm是没有安装成功的,需要自己下载对应的npm(下载地址:https://npm.taobao.org/mirrors/npm/),进行配置,或者也可以自己下载一个nodejs版本(下载地址:https://nodejs.org/download/release/),解压后复制到nvm目录,注意命名,如:v11.11.0,这样就不需要使用 nvm install 命令安装了。

(5)进入npm官网https://npm.taobao.org/mirrors/npm/下载nodejs对应版本的npm(注意:nodejs必须有对应的npm)。

下载完成,将解压后的文件复制到,C:\softtool\nvm\v10.15.3\node_modules目录下,并重命名为npm(注意必须重命名为npm)

 

还需要将npm解压后的bin文件夹下的四个文件复制到C:\softtool\nvm\v10.15.3目录下:

 

(6)安装完成,查看安装是否成功:

nvm list 列出本电脑上以安装所有的node版本

切换版本 nvm use node版本号:

Npm –v命令,查看npm的版本

可以看到npm 命令可以正常使用了。

 

 

Guess you like

Origin www.cnblogs.com/ejll/p/11229557.html