n supports installing Node.js on macOS, Linux (including WSL), and the usage is very simple:
n#
bash <(curl -L https://raw.githubusercontent.com/tj/n/master/bin/n) lts
Or for convenience, you can use:
bash <(curl -L mayi.ee/n) lts
You can replace lts with the following versions:
lts- Long-term support version (recommended)latest,current- Latest version10.16.0or other specified versions
For more information, please refer to the n GitHub page: https://github.com/tj/n
Using n in China
export NODE_MIRROR=http://mirrors.cloud.tencent.com/nodejs-release/
# Then execute the n command normally bash <(curl -L mayi.ee/n) lts
nvm#
n is simple, but it requires root permissions. With nvm, you can install Node.js without root user. Install nvm:
curl -L https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
Or for convenience, you can use:
curl -L mayi.ee/nvm | bash
Install the latest version of Node.js:
nvm install nodenvm use node
Install the latest LTS version of Node.js:
nvm install --ltsnvm use --lts
Install a specific version of Node.js:
nvm install 14.7.0nvm use 14.7.0
Using nvm in China
export NVM_NODEJS_ORG_MIRROR=http://mirrors.cloud.tencent.com/nodejs-release
# Then execute the nvm command normally nvm install --lts