卸载和重新安装节点 [英] Uninstalling and reinstalling node

查看:92
本文介绍了卸载和重新安装节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在我的 MacBook 上卸载并重新安装 node 和 npm.

到目前为止我已经完成了:

  1. sudo rm -rf/usr/local/lib/node_modules/npm/
  2. brew 卸载节点
  3. brew unlink 节点
  4. sudo rm -rf [任何和所有与节点相关的文件和目录]
  5. 酿造医生
  6. 酿造西梅
  7. brew 安装节点
  8. 酿造链接节点

在链接之前,每一步都可以正常工作.当我尝试 brew link --overwite node 时,出现此错误:

链接/usr/local/Cellar/node/0.10.33...

错误:无法符号链接 include/node/ares.h/usr/local/include/node 不可写.

这里是相关的堆栈溢出:如何完全卸载 Node.js,并从头重新安装 (Mac OS X)

这可能是调整顺序的问题.有没有人经历过这个过程并有任何提示?我注意到有人已经尝试在我也在使用的生产笔记本电脑上安装 node 并遇到相同的 brew 链接错误.

解决方案

尝试 sudo chown -R $(whoami)/usr/local/ 然后重新运行 brew link --overwrite node

编辑这与我最近两次必须 brew link node 遇到的问题相同,它解决了我的问题.

^^^^^^^^^^^^^^^^^^^^^^^

这是不应该做的.虽然它对给出的问题有效,鲁莽.不要像我以前那样相信您在互联网上阅读的所有内容.;) 以下是从 OSX 卸载 node.js 的多种方法,然后是解决此问题中出现的问题的更好方法.所有这些都是在 google 上找到的……通常会带我回到 StackOverflow.基本思想是一切都需要进行.

NPM(最安全)

sudo npm uninstall npm -g 删除所有文件.

sudo rm -rf/usr/local/lib/node \/usr/local/include/node \/usr/local/lib/node_modules \/usr/local/include/node_modules \/var/db/receipts/org.nodejs.* 删除无关的 bash 路径名.

如果您从 Node.js 网站安装

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

您可以尝试的脚本(带有自制软件)

这个更新比下面列出的下一个更新得更频繁,而且非常有条理.它确实尝试使用一些 brew 命令,因此如果您不使用自制软件,请不要使用它.它确实有一个所有问题目录的列表,这很好.来源.更多信息. 忽略对的建议chown 命令作为删除节点应该在不更改关键系统目录的权限的情况下完成.

  1. curl -O https://raw.githubusercontent.com/DomT4/scripts/master/OSX_Node_Removal/terminatenode.sh
  2. chmod +x/path/to/terminatenode.sh
  3. ./terminatenode.sh

您可以尝试的另一种脚本

这个要点是由 NiceRobot 创建的.Gist 在这里.请在运行之前阅读它以确保您可以轻松运行它脚本.与所有这些选项一样,它确实需要 sudo.

  1. curl -ksO https://gist.github.com/nicerobot/2697848/raw/uninstall-node.sh 下载脚本.
  2. chmod u+x ./uninstall-node.sh 允许您执行脚本.
  3. ./uninstall-node.sh 运行脚本
  4. which node 检查节点是否仍然安装.如果是,请选择其他选项.
  5. rm uninstall-node.sh 删除脚本.

这个问题提出的具体问题可以通过以下方式处理.感谢大家的意见/建议.希望所有这些都可以帮助某人,因为所有这些都可以在一个答案中找到.

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

sudo rm -rf/usr/local/include/node_modules

参考资料

  1. NiceRobot
  2. 关于 StackOverflow 的另一个问答
  3. 本网站.

I'm in the process of uninstalling and reinstalling node and npm on my MacBook.

So far I've done:

  1. sudo rm -rf /usr/local/lib/node_modules/npm/
  2. brew uninstall node
  3. brew unlink node
  4. sudo rm -rf [any and all node-related files and directories]
  5. brew doctor
  6. brew prune
  7. brew install node
  8. brew link node

Every step works fine up until the link. When I try brew link --overwite node, I get this error:

Linking /usr/local/Cellar/node/0.10.33...

Error: Could not symlink include/node/ares.h /usr/local/include/node is not writable.

Here's the related stack overflow: How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)

It may be a matter of tweaking the sequence. Has anyone gone through the process and have any tips? I noticed someone has already tried to install node on the production laptop I'm also using and run into the identical brew link error.

解决方案

Try sudo chown -R $(whoami) /usr/local/ then rerun brew link --overwrite node

edit This is the same problem I had the last two times I had to brew link node and it solved my problem.

^^^^^^^^^^^^^^^^^^^^^^^

This is what not to do. Although it does work for the question given, it is reckless. Don't believe everything you read on the internet like I used to. ;) Below are a number of ways to uninstall node.js from OSX in general followed by a better way to solve the problem presented in this question. All of this was found with google... and usually lead me back to StackOverflow. The basic idea being that everything needs to go.

NPM(Safest)

sudo npm uninstall npm -g Removes all files.

sudo rm -rf /usr/local/lib/node \ /usr/local/include/node \ /usr/local/lib/node_modules \ /usr/local/include/node_modules \ /var/db/receipts/org.nodejs.* Removes extraneous bash pathnames.

If You Installed From The Node.js Website

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

A Script You Can Try(w/ homebrew)

This one is updated more frequently then the next one listed below and is very methodical. It does attempt to use some brew commands so dont use it if you don't use homebrew. It does have a list of all problem directories, which is nice. Source. More info. Ignore the suggestion for the chown command at the end as removal of node should be done without changing permissions of critical system directories.

  1. curl -O https://raw.githubusercontent.com/DomT4/scripts/master/OSX_Node_Removal/terminatenode.sh
  2. chmod +x /path/to/terminatenode.sh
  3. ./terminatenode.sh

Another Script You Can Try

This gist was created by NiceRobot. Gist is here. Please read it before you run it to make sure you're comfortable running this script. It does require sudo as all of these options do.

  1. curl -ksO https://gist.github.com/nicerobot/2697848/raw/uninstall-node.sh Downloads the script.
  2. chmod u+x ./uninstall-node.sh Enables execution of the script by you.
  3. ./uninstall-node.sh Runs the script
  4. which node Checks to see if node is still installed. If so, choose another option.
  5. rm uninstall-node.sh Deletes the script.

The specific problem presented by this question can be dealt with with the following. Thanks for everyone's comments/recommendations. Hope all this helps someone now that all this can be found in one answer.

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

sudo rm -rf /usr/local/include/node_modules

References

  1. NiceRobot
  2. Another Q&A on StackOverflow
  3. This website.

这篇关于卸载和重新安装节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆