scibrokes / mytools

储存一些编程相关软件的仓库。
https://gitee.com/englianhu
GNU General Public License v3.0
0 stars 0 forks source link

在🚩🇨🇳🏹中科红旗 RedFlag Linux (🍥Debian)安装`npm`和`nodejs`应用 #12

Closed englianhu closed 2 years ago

englianhu commented 2 years ago
## https://nodejs.org/en
curl -qL https://nodejs.org/dist/latest/ | sed -n '/linux-x64.tar.gz/p'
wget https://nodejs.org/dist/v18.8.0/node-v18.8.0-linux-x64.tar.xz
which node
# /usr/bin/node
which npm
# /usr/bin/npm

sudo rm -rf -R /usr/bin/node
sudo rm -rf -R /usr/lib/node
sudo rm -rf -R /usr/bin/npm
sudo tar -xf node-v18.8.0-linux-x64.tar.xz -C /usr/lib/
sudo rm -rf node-v18.8.0-linux-x64.tar.xz
sudo mv /usr/lib/node-v18.8.0-linux-x64 /usr/lib/node
sudo chmod 777 -R /usr/lib/node
sudo chmod 777 -R /usr/lib/npm
## /usr/lib/node/

## 方案 01
npm ci
npm config ls
curl -qL https://www.npmjs.com/install.sh | sh

echo "export PATH=/usr/lib/node/bin:${PATH}" | sudo tee /etc/profile.d/node.sh
source /etc/profile.d/node.sh
node -v

## 方案 02
echo "export PATH=/usr/lib/node/bin:${PATH}" | sudo tee -a $HOME/.profile #source
source $HOME/.profile
node -v

参考文献: