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
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/16163585.html
未经授权禁止转载,违者必究!