node-install-on-mac

203 阅读1分钟

node install on mac so easily , in 1 line.

  • install with brew
  • install with n
  • install with nvm (recommend)

node install on mac with brew

brew search node
# install
brew install node@14


# switch version
brew unlink node@18
brew link --overwrite --force node@14

node install on mac with n

  • n install if it has not been install.
brew install n

# list remote node version
n ls-remote;
# n ls-remote lts

# del some node version
# n rm 0.9.4 v0.10.0;

# del all cached version
# n prune

# get the path of some downloaded version
# n which 6.14.3

# run a downloaded node version 
# n run 8.11.3 --debug some.js

# display diagnostics to help resolve problems:
# n docker

node isntall on mac with nvm

  • nvm install if it has not been install
  • install 14.x lts verion here
nvm --version > /dev/null 2>&1; [ $? -ne 0 ] && curl -fsSL https://ghproxy.com/https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash ; source ~/.zshrc;nvm install 14 --lts;
# nvm --version > /dev/null 2>&1; [ $? -ne 0 ] && brew install nvm;

# nvm --help

# nvm ls-remote
# nvm ls-remote --lts
# vm ls-remote --lts=argon

# nvm install --lts
# nvm install 14 --lts
# 14.21.3
# nvm install 12 --lts
# 12.22.12

# nvm run node --version
# nvm which 18.7.1
# nvm which 14.21.3

# nvm use node
# nvm use 14.21.3
# nvm use 12.22.12

# npm i -g pnpm@6
# npm ls -g --depth=0
# npm uninstall -g pnpm

# nvm version

# ls ~/.nvm/versions/node

# del nvm
# rm -rf ~/.nvm

source code

tj/n - github

nvm-sh/nvm - github

next reading

pnpm install on mac