如何完全卸载 Node.js,然后从头重新安装(Mac OS X)

How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)(如何完全卸载 Node.js,然后从头重新安装(Mac OS X))

本文介绍了如何完全卸载 Node.js,然后从头重新安装(Mac OS X)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使我安装了 brew node 和 NVM install v0.6.19,我的 node 版本始终是 v0.6.1-pre.

My version of node is always v0.6.1-pre even after I install brew node and NVM install v0.6.19.

我的节点版本是:

node -v
v0.6.1-pre

NVM 这么说(在我第一次在一个 bash 终端中安装一个版本的节点之后):

NVM says this (after I install a version of node for the first time in one bash terminal):

nvm ls
v0.6.19
current:    v0.6.19

但是当我重新启动 bash 时,我看到的是这样的:

But when I restart bash, this is what I see:

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

那么这个幻像节点 0.6.1-pre 版本在哪里,我该如何摆脱它?我正在尝试通过 NPM 安装库,以便我可以处理项目.

So where is this phantom node 0.6.1-pre version and how can I get rid of it? I'm trying to install libraries via NPM so that I can work on a project.

我尝试在 NVM 之前使用 BREW 进行更新,使用 brew updatebrew install node.我尝试删除 /usr/local/include 中的node"目录以及 /usr/local/lib 中的node"和node_modules".我已经尝试卸载 npm 并按照 这些 说明重新安装.

I tried using BREW to update before NVM, using brew update and 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. I've tried uninstalling npm and reinstalling it following these instructions.

所有这一切都是因为我试图更新旧版本的节点来安装zipstream"库.现在我的用户目录中有文件夹,并且节点版本仍然不是最新的,即使 NVM 说它使用的是 0.6.19.

All of this because I was trying to update an older version of node to install the "zipstream" library. 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.

理想情况下,我想卸载 nodejs、npm 和 nvm,然后在我的系统上从头开始重新安装整个东西.

推荐答案

显然,有一个 /Users/myusername/local 文件夹包含一个 include>nodelibnodenode_modules.我不知道它是如何以及为什么创建而不是在我的 /usr/local 文件夹中创建的.

Apparently, there was a /Users/myusername/local folder that contained a include with node and lib with node and node_modules. How and why this was created instead of in my /usr/local folder, I do not know.

删除这些本地引用修复了幻影 v0.6.1-pre.如果有人有解释,我会选择它作为正确答案.

Deleting these local references fixed the phantom v0.6.1-pre. If anyone has an explanation, I'll choose that as the correct answer.

您可能还需要执行其他说明:

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*}

相当于(同上)...

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

或(同上)分解...

完全卸载node+npm的方法如下:

To completely uninstall node + npm is to do the following:

  1. 转到 /usr/local/lib 并删除所有 nodenode_modules
  2. 转到 /usr/local/include 并删除所有 nodenode_modules 目录
  3. 如果您使用 brew install node 进行安装,则在终端中运行 brew uninstall node
  4. 检查您的主目录中是否有任何 locallibinclude 文件夹,并删除任何 nodenode_modules 从那里开始
  5. 转到 /usr/local/bin 并删除所有 node 可执行文件
  1. go to /usr/local/lib and delete any node and node_modules
  2. go to /usr/local/include and delete any node and node_modules directory
  3. if you installed with brew install node, then run brew uninstall node in your terminal
  4. check your Home directory for any local or lib or include folders, and delete any node or node_modules from there
  5. go to /usr/local/bin and delete any node executable

您可能还需要这样做:

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

另外,NVM 会修改 $HOME/.bashrc 中的 PATH 变量,该变量必须是 手动还原.

Additionally, NVM modifies the PATH variable in $HOME/.bashrc, which must be reverted manually.

然后下载 nvm 并按照说明安装节点.我相信最新版本的 node 带有 npm,但你也可以重新安装它.

Then download nvm and follow the instructions to install node. The latest versions of node come with npm, I believe, but you can also reinstall that as well.

这篇关于如何完全卸载 Node.js,然后从头重新安装(Mac OS X)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何完全卸载 Node.js,然后从头重新安装(Mac OS X)

基础教程推荐