我从Mac上的pkg文件安装了NodeJS。现在我需要卸载它。请告诉我该怎么做。我试图从此列表中删除文件:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom
但是节点仍在我的计算机上。
我从Mac上的pkg文件安装了NodeJS。现在我需要卸载它。请告诉我该怎么做。我试图从此列表中删除文件:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom
但是节点仍在我的计算机上。
Answers:
我跑了:
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.*
编码为要点2697848
更新
收据.bom
文件名似乎已更改,因此您可能需要在其中替换org.nodejs.pkg.bom
为org.nodejs.node.pkg.bom
。要点已相应更新。
rm -rf /Users/me/local/bin/node
现在摇摆的节点不稳定!
如果您是从他们的网站安装Node的,请尝试以下操作:
sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*}
这对我有用,但是如果您有任何疑问,我的GitHub是'mnafricano'。
/usr/local/lib/dtrace/node.d
/var/db/receipts/org.nodejs.*
在之前的帖子之后,这是我使用的完整列表
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
/usr/local/share/doc/node/gdbinit
和/usr/local/share/systemtap/tapset/node.stp
为了删除“本机” node.js安装,我使用了先前答案中建议的方法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
只有在那之后,我才能使用Homebrew安装node.js。
sudo rm /usr/local/bin/node /usr/local/share/man/man1/node.1 /usr/local/lib/dtrace/node.d
我添加了AhrB的列表,同时附加了三个文件。这是我使用过的完整列表:
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
一个方便的脚本扩展了以前的答案。
#!/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}
将其保存到文件并运行:
# bash filename.sh
经过反复试验,以下代码有效,并且这些目录不可写,因此,我将其删除,最后能够替换node&npm。
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
sudo npm uninstall npm -g
比下面给出的答案更安全,更容易吗?