Nodejs下载地址:https://nodejs.org/zh-cn/download/package-manager
上述链接下载好对应版本的软件包后,我存放到 /evn/nodejs 目录下(根据自己实际情况设置)
sudo ln -s /evn/nodejs/node-v16.18.0-linux-x64/bin/npm /usr/local/bin/
sudo ln -s /evn/nodejs/node-v16.18.0-linux-x64/bin/node /usr/local/bin/
npm config set registry https://registry.npmmirror.com/
npm config get registry
npm install -g cnpm --registry=https://registry.npmmirror.com/
sudo ln -s /evn/nodejs/node-v16.18.0-linux-x64/bin/cnpm /usr/local/bin/
# installs nvm (Node Version Manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# download and install Node.js (you may need to restart the terminal)
nvm install 20
# verifies the right Node.js version is in the environment
node -v # should print `v20.15.1`
# verifies the right NPM version is in the environment
npm -v # should print `10.7.0`
相关命令
# installs fnm (Fast Node Manager)
curl -fsSL https://fnm.vercel.app/install | bash
# download and install Node.js
fnm use --install-if-missing 20
# verifies the right Node.js version is in the environment
node -v # should print `v20.15.1`
# verifies the right NPM version is in the environment
npm -v # should print `10.7.0`
相关命令