[Node] Notes nvs use

Original Address

In use nvsbefore it has been using nvm windowsthis tool, with the also very cool, not long ago to see science text, so would like to try, then tried in windowsa rollover, so here record it. Look at the Popular Science article: Use nvs manage local Node.js version

windowsUnder Installation

Recommended cmd manual installation steps

git bash environment configuration

# ~/.bashrc 添加下面的环境配置
# 根据你安装的路径选择$ProgramData 或者 $LOCALAPPDATA
export NVS_HOME=$LOCALAPPDATA/nvs
. $NVS_HOME/nvs.sh
复制代码

git bash in nvserror can not find command

nvs v1.5.1Use MSIor choco install nvsafter installation can be used normally, but will be missing nvs.shif you are git bashunder use nvswill not find the command, subsequent versions will fix the problem. Recommended cmd manual installation step is not the problem.

nvsAnd the npmcommand does not take effect

After installing the new terminal window nvsand npmwhen not to take effect, pay attention to log off again, or reboot the system.

Note: in particular, for the first time nvs link, and found nodeand npmwill not take effect, the best log off again.

Shared npmglobal module

First, we do not recommend cross-version of the common global module, unless you know what you're doing.

Popular Science article: Use nvs manage local Node.js version has been introduced for how to set.

# 使用git bash创建
mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global
复制代码
# .bashrc中添加全局模块的路径
# 注意~/.npm-global/   不是~/.npm-global/bin
# windows 10下没有bin文件夹,所以最好检查下。。。
echo "export PATH=~/.npm-global/:$PATH" >> ~/.bashrc

source ~/.bashrc
复制代码

Note: ( nvs v1.5.1)

  1. Pay attention to check the global configuration path module is correct (pit)

cmdAnd power shelllower global module add environment variables

Through the above configuration git bash, the global installed npmnormal work of the module, but in cmdor power shellwill find not find the command, tried to add a system variable , but still does not take effect, put a final issues, the official gave the solution .

# 设置完如果不生效,新开一个命令行窗口尝试(如果不行,注销重新登录)
setx PATH "%PATH%;%USERPROFILE%\.npm-global"
复制代码

After setting: cmder, cmd, powershell, cygwinall in force

note:

  1. nvs useIt is to change the current shellwindow nodeversion, not the global environment (the difference nvm)
  2. nvs linkIt is changing the global environment nodeversion

reference

Popular Science article: Use nvs manage local Node.js version

Migrating from nvm to nvs

cmder using .bashrc

VS Code Support - Node Version Switcher

xizhibei Node Version Manager

Windows: when use npm prefix share global modules fails

setx

ss64 setx

Guess you like

Origin blog.csdn.net/weixin_34234721/article/details/91382867