xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

change nvm default Node.js version All In One

change nvm default Node.js version All In One

$ nvm alias default 16.14.2

$ nvm -h

$ nvm ls

$ nvm ls-remote

$ nvm ls-remote --lts

$ nvm install 16.14.2

# 临时使用一次
$ nvm use 16.14.2

# 永久修改默认值 ✅
$ nvm alias default 16.14.2

# 默认 16 的最新版 latest version
$ nvm alias default 16

# nvm
$ nvm -h
$ nvm ls
$ nvm ls-remote | grep "Latest LTS"
$ nvm install 18.16.0
$ nvm use 18.16.0

$ nvm alias default 18.16.0
$ nvm alias default node


$ which node
# /home/pi/.nvm/versions/node/v18.16.0/bin/node

demo


# 永久修改默认值
$ nvm alias default 16.14.2
      
➜  ~ node -v
v16.14.2
➜  ~ which node
/Users/xgqfrms-mbp/.nvm/versions/node/v16.14.2/bin/node

zsh

$ code ~/.zshrc

$ source ~/.zshrc
# source .zshrc

# nvm config
export NVM_DIR="$HOME/.nvm"
  [ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh"  # This loads nvm
  [ -s "/usr/local/opt/nvm/etc/bash_completion" ] && . "/usr/local/opt/nvm/etc/bash_completion"  # This loads nvm bash_completion


# Node.js V16
export PATH="$PATH:/usr/local/bin:$PATH"
# export PATH="$PATH:/usr/local/bin/node:$PATH"
# export PATH="$PATH:/usr/local/bin/npm:$PATH"

which command

find Node.js install path on Linux/macOS

$ which 

$ which node
/Users/xgqfrms-mbp/.nvm/versions/node/v12.18.0/bin/node

Node.js default install path

/usr/local/bin === /usr/local/bin/node & /usr/local/bin/npm

https://davescripts.com/location-of-nodejs-files-on-mac-os-x

refs

https://stackoverflow.com/questions/47190861/how-can-the-default-node-version-be-set-using-nvm

https://www.cnblogs.com/xgqfrms/tag/nvm/

https://www.cnblogs.com/xgqfrms/tag/which/

https://unix.stackexchange.com/questions/112276/where-node-js-was-installed/699476#699476

https://stackoverflow.com/questions/20031849/how-can-i-find-my-node-js-files-in-linux-usr-bin-node-is-not-working



©xgqfrms 2012-2020

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2022-04-19 11:06  xgqfrms  阅读(156)  评论(1编辑  收藏  举报