MacOS X 10 10解除安裝Node

2021-07-10 17:05:49 字數 2282 閱讀 6315

最近好像把node給弄壞了,在使用npm init的時候系統報錯:

press ^c at any time to quit.

npm err! darwin 14.5.0

npm err! argv "/usr/local/bin/node"

"/usr/local/bin/npm"

"init"

npm err! node v4.4.1

npm err! npm v2.14.20

npm err! code module_not_found

npm err! cannot find module 'spdx'

npm err!

npm err! if you need help, you may report this error at:

npm err!

原本通過官方的pkg檔案安裝的v0.12.x版本,node預設在/usr/local/bin下,webstorm可以直接識別位置

想同時儲存v0.12.x版本和安裝v4.x.x版本,所以使用了nvm切換了node版本,後來發現nvm的安裝方式不純潔,即並沒有安裝在/usr/local/bin下導致強迫症發作,一定要裝個純潔版本,找到了n這個工具~

在不懂nvm和n的原理的情況下,不知道怎麼搞的就切換錯了。。。

所以原因是——版本紊亂了。。。。我準備將node完全解除安裝後重灌

第一篇是nvm與n的區別,第二篇具體給出了nvm切換版本的例子。總的來說:

使用homebrew安裝nvm,並且在zsh的環境下安裝的同學,可能會產生衝突,導致nvm的$nvm_dir指向了/usr/local/opt/nvm,詳見:

使用以下命令,參考自[uninstall nodejs from osx yosemite(可能需要翻牆)][4]

# first:

lsbom -f

-l-s -pf /var/db/receipts/org.nodejs.pkg.bom | while

read f; do

sudo rm /usr/local/$; done

sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*

# to recap, the best way (i've found) to completely uninstall node + npm is to do the following:

# go to /usr/local/lib and delete any node and node_modules

cd /usr/local/lib

sudo rm -rf node*

# go to /usr/local/include and delete any node and node_modules directory

cd /usr/local/include

sudo rm -rf node*

# if you installed with brew install node, then run brew uninstall node in your terminal

brew uninstall node

# check your home directory for any "local" or "lib" or "include" folders, and delete any "node" or "node_modules" from there

# go to /usr/local/bin and delete any node executable

cd /usr/local/bin

sudo rm -rf /usr/local/bin/npm

sudo rm -rf /usr/local/bin/node

ls -las

# you may need to do the additional instructions as well:

sudo rm -rf /usr/local/share/man/man1/node.1

sudo rm -rf /usr/local/lib/dtrace/node.d

sudo rm -rf ~/.npm

Mac OSX下解除安裝Nodejs

1.拷貝如下 放到乙個sh檔案中 如uninstall node.sh 1 2 3 4 5 6 7 8 bin bash lsbom f l s pf var db receipts org.nodejs.pkg.bom whilereadi do sudo rm usr local done su...

Mac OS X 完全解除安裝MySQL

本文引用雲裡飛 mac os x 完全解除安裝mysql 執行下列命令 brew uninstall mysql sudo rm usr local var mysql sudo rm rf usr local mysql sudo rm rf library launchdaemons com.o...

Mac OS X 完全解除安裝MySQL

執行下列命令 sudo rm usr local mysql sudo rm rf usr local mysql sudo rm rf library startupitems mysqlcom sudo rm rf library preferencepanes my rm rf library...