如何完全卸載Node.js,然後從頭開始重新安裝(Mac OS X)

本文翻譯自:How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)

My version of node is always v0.6.1-pre even after I install brew node and NVM install v0.6.19. 我的節點版本始終是v0.6.1-pre,即使我安裝了brew節點並且NVM也安裝了v0.6.19。

My node version is: 我的節點版本是:

node -v
v0.6.1-pre

NVM says this (after I install a version of node for the first time in one bash terminal): NVM這樣說(我在一個bash終端中第一次安裝了一個版本的節點之後):

nvm ls
v0.6.19
current:    v0.6.19

But when I restart bash, this is what I see: 但是當我重新啓動bash時,這是我看到的:

nvm ls
v0.6.19
current:    v0.6.1-pre
default -> 0.6.19 (-> v0.6.19)

So where is this phantom node 0.6.1-pre version and how can I get rid of it? 那麼這個幻影節點0.6.1-pre版本在哪裏,我該如何擺脫它? I'm trying to install libraries via NPM so that I can work on a project. 我正在嘗試通過NPM安裝庫,以便可以在項目上工作。

I tried using BREW to update before NVM, using "brew update" and "brew install node". 我嘗試使用BREW在NVM之前進行更新,使用“ brew update”和“ brew install node”。 I've tried deleting the "node" directory in my /usr/local/include and the "node" and "node_modules" in my "/usr/local/lib". 我嘗試刪除/ usr / local / include中的“節點”目錄以及“ / usr / local / lib”中的“節點”和“ node_modules”。 I've tried uninstalling npm and reinstalling it following these instructions. 我已嘗試按照以下說明卸載npm並重新安裝。

All of this because I was trying to update an older version of node to install the "zipstream" library. 所有這些都是因爲我試圖更新節點的舊版本以安裝“ zipstream”庫。 Now there's folders in my users directory, and the node version STILL isn't up to date, even though NVM says it's using 0.6.19. 現在,我的用戶目錄中有文件夾,並且節點版本STILL不是最新的,即使NVM表示它正在使用0.6.19。

Ideally, I'd like to uninstall nodejs, npm, and nvm, and just reinstall the entire thing from scratch on my system. 理想情況下,我想卸載nodejs,npm和nvm,然後從頭開始重新安裝整個系統。


#1樓

參考:https://stackoom.com/question/ktta/如何完全卸載Node-js-然後從頭開始重新安裝-Mac-OS-X


#2樓

Apparently, there was a /Users/myusername/local folder that contained a include with node and lib with node and node_modules . 顯然,存在一個/Users/myusername/local文件夾,其中包含一個include nodelib以及nodenode_modules How and why this was created instead of in my /usr/local folder, I do not know. 我不知道是如何以及爲什麼創建它的,而不是在我的/usr/local文件夾中創建的。

Deleting these local references fixed the phantom v0.6.1-pre. 刪除這些本地引用可修復幻影v0.6.1-pre。 If anyone has an explanation, I'll choose that as the correct answer. 如果有人有解釋,我會選擇它作爲正確答案。

EDIT: 編輯:

You may need to do the additional instructions as well: 您可能還需要執行其他說明:

sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}

which is the equivalent of (same as above)... 等價於(與上述相同)...

sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* /usr/local/lib/dtrace/node.d ~/.npm ~/.node-gyp 

or (same as above) broken down... 或(與上述相同)損壞...

To completely uninstall node + npm is to do the following: 要完全卸載node + npm,請執行以下操作:

  1. go to /usr/local/lib and delete any node and node_modules 轉到/ usr / local / lib並刪除任何節點node_modules
  2. go to /usr/local/include and delete any node and node_modules directory 轉到/ usr / local / include並刪除任何nodenode_modules目錄
  3. if you installed with brew install node , then run brew uninstall node in your terminal 如果你安裝了沖泡安裝節點 ,然後在你的終端上運行的BREW卸載節點
  4. check your Home directory for any local or lib or include folders, and delete any node or node_modules from there 檢查主目錄中是否有任何本地lib包含文件夾,並從此處刪除任何節點node_modules
  5. go to /usr/local/bin and delete any node executable 轉到/ usr / local / bin並刪除任何節點可執行文件

You may also need to do: 您可能還需要執行以下操作:

sudo rm -rf /opt/local/bin/node /opt/local/include/node /opt/local/lib/node_modules
sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node.1 /usr/local/lib/dtrace/node.d

Additionally, NVM modifies the PATH variable in $HOME/.bashrc , which must be reverted manually . 另外,NVM修改$HOME/.bashrc的PATH變量,該變量必須手動還原

Then download nvm and follow the instructions to install node. 然後下載nvm並按照說明安裝節點。 The latest versions of node come with npm , I believe, but you can also reinstall that as well. 我相信node的最新版本是npm附帶的,但是您也可以重新安裝它。


#3樓

I have been hit by an issue during uninstall of Node.js on my mac. 在Mac上卸載Node.js時遇到問題。 I had some strange behavior like npm is still their even after having removing it with all this. 即使刪除了所有這些內容,我仍然有一些奇怪的行爲,例如npm仍然是他們的行爲。

It was because I had an old install done with macport. 這是因爲我用macport完成了舊安裝。 So you also have to uninstall it using port: 因此,您還必須使用port卸載它:

sudo port uninstall nodejs

It may have install many different versions of Node.js so uninstall them all (one by one). 它可能安裝了許多不同版本的Node.js,因此(一一卸載)它們。


#4樓

On Mavericks I install it from the node pkg (from nodejs site) and I uninstall it so I can re-install using brew. 在Mavericks上,我從node pkg(從nodejs站點)安裝它,並卸載了它,因此可以使用brew重新安裝。 I only run 4 commands in the terminal: 我只在終端中運行4個命令:

  1. sudo rm -rf /usr/local/lib/node_modules/npm/
  2. brew uninstall node
  3. brew doctor
  4. brew cleanup --prune-prefix

If there is still a node installation, repeat step 2. After all is ok, I install using brew install node 如果仍然有節點安裝,請重複步驟2。一切正常之後,我將使用brew install node進行brew install node


#5樓

I know this post is a little dated but just wanted to share the commands that worked for me in Terminal when removing Node.js. 我知道這篇文章有些過時,但是隻是想分享刪除Node.js時在Terminal中對我有用的命令。

lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do  sudo rm /usr/local/${f}; done

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

UPDATE: 23 SEP 2016 更新: 23 SEP 2016


If you're afraid of running these commands... 如果您擔心運行這些命令...

Thanks to jguix for this quick tutorial . 感謝jguix提供了this quick tutorial

First, create an intermediate file: 首先,創建一箇中間文件:

lsbom -f -l -s -pf /var/db/receipts/org.nodejs.node.pkg.bom >> ~/filelist.txt

Manually review your file (located in your Home folder) 手動檢查您的文件(位於Home文件夾中)

 ~/filelist.txt

Then delete the files: 然後刪除文件:

cat ~/filelist.txt | while read f; do sudo rm /usr/local/${f}; done

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

For 10.10.5 and above 適用於10.10.5及以上

Thanks Lenar Hoyt 感謝Lenar Hoyt

Gist Comment Source: gistcomment-1572198 要點評論來源: gistcomment-1572198

Original Gist: TonyMtz/d75101d9bdf764c890ef 原始要點: TonyMtz/d75101d9bdf764c890ef

lsbom -f -l -s -pf /var/db/receipts/org.nodejs.node.pkg.bom | while read f; do sudo rm /usr/local/${f}; done

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

#6樓

maybe you need to make 也許你需要

hash -r 

it helps with problem of symlink 它有助於解決符號鏈接問題

$ node -v
$ bash: /opt/local/bin/node: No such file or directory
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章