# 在Mac OS X下卸载Node.js

因为[准备nodejs开发环境](/cloud-atlas-draft/develop/nodejs/startup/nodejs_develop_environment.md)，准备从头开始，所以想要卸载掉原先通过`pkg`安装的node.js，然后重新通过`nvm`来管理node.js版本。

对于实用官方pkg安装包，使用如下命令卸载

```
cd /
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.node.pkg.bom \
| while read i; do
  sudo rm ${i}
done
sudo rm -rf /usr/local/lib/node \
     /usr/local/lib/node_modules \
     /var/db/receipts/org.nodejs.*
```

> 注意，首先要检查一下 `lsbom -f -l -s -pf /var/db/receipts/org.nodejs.node.pkg.bom` ，确保删除掉的文件是 `/usr/local/include/node/...` 这样的文件，避免误删

## 参考

* [在Mac OS X下安装和卸载Node.js的方法](http://www.micmiu.com/lang/nodejs/mac-osx-nodejs-install/) － 非常完善的总结方法
* [How do I uninstall nodejs installed from pkg (Mac OS X)?](http://stackoverflow.com/questions/9044788/how-do-i-uninstall-nodejs-installed-from-pkg-mac-os-x) - stackoverflow上的卸载方法，准确实用


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://huataihuang.gitbook.io/cloud-atlas-draft/develop/nodejs/startup/uinstall_nodejs_in_os_x.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
