How do I uninstall nodejs installed from pkg (Mac OS X)?
我在Mac上安装了pkg文件中的nodejs。现在我需要卸载它。请告诉我怎么做。我尝试从此列表中删除文件:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom
但节点仍在我的计算机上。
我跑了:
1 2 3 4 5 6 7 | lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom \ | while read i; do sudo rm /usr/local/${i} done sudo rm -rf /usr/local/lib/node \ /usr/local/lib/node_modules \ /var/db/receipts/org.nodejs.* |
编码为GIST 2697848
更新似乎收据
如果您从他们的网站安装了节点,请尝试以下操作:
1 | sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*} |
这对我很有用,但如果你有任何问题,我的Github是"南非佬"。
以下是我以前的文章,下面是我使用的完整列表
1 2 3 4 5 6 7 | sudo npm uninstall npm -g sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /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/lib/dtrace/node.d brew install node |
为了删除"native"node.js安装,我使用了前面答案
但是,我还必须删除以下两个目录:
1 | sudo rm -rf /usr/local/include/node /Users/$USER/.npm |
只有在这之后,我才能用自制安装node.js。
这是我使用的命令的完整列表(多亏了上面的海报):
1 2 3 4 5 | sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /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 brew install node |
我拿了AHRB的清单,同时又附加了三个文件。以下是我使用的完整列表:
1 2 3 4 5 6 7 8 9 | sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /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/bin/npm sudo rm /usr/local/share/systemtap/tapset/node.stp sudo rm /usr/local/lib/dtrace/node.d # In case you want to reinstall node with HomeBrew: # brew install node |
使用NPM卸载。运行
/usr/local/lib/node_modules \
/var/db/receipts/org.nodejs.*
在前面的答案基础上扩展的一个小便利脚本。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #!/bin/bash # Uninstall node.js # # Options: # # -d Actually delete files, otherwise the script just _prints_ a command to delete. # -p Installation prefix. Default /usr/local # -f BOM file. Default /var/db/receipts/org.nodejs.pkg.bom CMD="echo sudo rm -fr" BOM_FILE="/var/db/receipts/org.nodejs.pkg.bom" PREFIX="/usr/local" while getopts"dp:f:" arg; do case $arg in d) CMD="sudo rm -fr" ;; p) PREFIX=$arg ;; f) BOM_FILE=$arg ;; esac done lsbom -f -l -s -pf ${BOM_FILE} \ | while read i; do $CMD ${PREFIX}/${i} done $CMD ${PREFIX}/lib/node \ ${PREFIX}/lib/node_modules \ ${BOM_FILE} |
将其保存到文件并运行:
1 | # bash filename.sh |
以下内容在尝试和错误之后都有效,这些目录不可写,因此,我删除了它们,最终能够替换节点和NPM。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | sudo rm -rf /usr/local/share/systemtap sudo rm -rf /usr/local/share/doc/node sudo rm -rf /usr/local/Cellar/node/9.11.1 brew install node ==> Downloading https://homebrew.bintray.com/bottles/node-9.11.1.high_sierra.bottle.tar.gz Already downloaded: /Users/xxx/Library/Caches/Homebrew/node-9.11.1.high_sierra.bottle.tar.gz ==> Pouring node-9.11.1.high_sierra.bottle.tar.gz ==> Caveats Bash completion has been installed to: /usr/local/etc/bash_completion.d ==> Summary ?? /usr/local/Cellar/node/9.11.1: 5,125 files, 49.7MB node -v v9.11.1 npm -v 5.6.0 |
我也不得不删除以下文件,因为BREW在稍后手动删除所有文件后,在安装过程中抱怨过。
1 2 3 | /usr/local/share/doc/node/gdbinit /usr/local/share/systemtap/tapset/node.stp |
然后做下面的事情
1 2 3 | brew install node brew link node |