将下面的指令复制到终端后直接执行, 注意因为需要sudo权限需要输入密码才可以正常执行
sudo npm uninstall npm -g
sudo rm -rf /usr/local/lib/node
sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf /var/db/receipts/org.nodejs.*
sudo rm -rf /usr/local/include/node /Users/$USER/.npm*
sudo rm /usr/local/bin/node
sudo rm /usr/local/share/man/man1/node.1
sudo rm /usr/local/share/man/man1/npm-*
sudo rm /usr/local/share/man/man1/npm.1
sudo rm /usr/local/share/man/man1/npx.1
sudo rm /usr/local/share/man/man5/npm*
sudo rm /usr/local/share/man/man5/package.json.5
sudo rm /usr/local/share/man/man7/npm*
sudo rm /usr/local/lib/dtrace/node.d
执行完成之后查看本地nodejs状态
node -v