徹底卸載nodejs和npm然後使用nvm

sudo apt-get remove --purge npm
sudo apt-get remove --purge nodejs
sudo apt-get remove --purge nodejs-legacy
sudo apt-get autoremove(這個不要輕易運行)
​
#手動刪除 npm 相關目錄
rm -r /usr/local/bin/npm
rm -r /usr/local/lib/node-modules
rm -r /tmp/npm* 
rm -r /usr/local/n
rm -r /usr/local/lib/node_modules

git clone https://gitee.com/mirrors/nvm.git

./install.sh

另外開個終端就可以使用nvm了。

nvm install v12.18.0

安裝後效果如下:

(Python3.6) appleyuchi@Desktop:flink$ which node
/home/appleyuchi/.nvm/versions/node/v12.18.0/bin/node
(Python3.6) appleyuchi@Desktop:flink$ which npm
/home/appleyuchi/.nvm/versions/node/v12.18.0/bin/npm
nvm ls-remote(列出可以安裝的版本號)

npm init

npm install express --registry https://registry.npm.taobao.org

查看當前的源是不是淘寶:

npm config get registry

npm install -g @angular/cli(這裏必須全局)

 

 

如果卸載angular-cli如下:

nvm use v12.18.0
npm uninstall -g angular-cli
npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli@latest
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章