unbuntu 手动安装npm最新版
下载最新node包
指定版本:16.18.1
sudo wget https://nodejs.org/dist/v16.18.1/node-v16.18.1-linux-x64.tar.xz
新建目录
sudo mkdir -p /usr/local/lib/nodejs
解压缩
sudo tar -xJvf node-v16.18.1-linux-x64.tar.xz -C /usr/local/lib/nodejs
https://nodejs.org/download/release/v12.16.3/node-v12.16.3-linux-x64.tar.xz
v12.16.3
Nodejs
更新环境变量
export PATH=/usr/local/lib/nodejs/node-v16.18.1-linux-x64/bin:$PATH
. ~/.profile
做个链接
sudo ln -sf /usr/local/lib/nodejs/node-v16.18.1-linux-x64/bin/npm /usr/local/bin/
sudo ln -sf /usr/local/lib/nodejs/node-v16.18.1-linux-x64/bin/node /usr/local/bin/
sudo wget https://nodejs.org/dist/v18.12.1/node-v18.12.1-linux-x64.tar.xz
新建目录
sudo mkdir -p /usr/local/lib/nodejs
解压缩
sudo tar -xJvf node-v18.12.1-linux-x64.tar.xz -C /usr/local/lib/nodejs
Nodejs
更新环境变量
export PATH=/usr/local/lib/nodejs/node-v18.12.1-linux-x64/bin:$PATH
. ~/.profile
做个链接
sudo ln -sf /usr/local/lib/nodejs/node-v18.12.1-linux-x64/bin/npm /usr/local/bin/
sudo ln -sf /usr/local/lib/nodejs/node-v18.12.1-linux-x64/bin/node /usr/local/bin/
删除nodejs
- sudo apt-get remove –purge npm
- sudo apt-get remove –purge nodejs
- sudo apt-get remove –purge nodejs-legacy
- sudo apt-get autoremove
- #手动删除 npm 相关目录
- sudo rm -r /usr/local/bin/npm
- sudo rm -r /usr/local/lib/node-moudels
- sudo find / -name npm
- sudo rm -r /tmp/npm*
sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*}
自动安装
sudo apt install curl && sudo apt install make
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash –
sudo apt install -y nodejs
发表评论