选择命令行版本:
🌐 Synopsis
看到你走真难过。
🌐 So sad to see you go.
sudo npm uninstall npm -g
或者,如果失败,请获取 npm 源代码,然后执行以下操作:
🌐 Or, if that fails, get the npm source code, and do:
sudo make uninstall
🌐 More Severe Uninstalling
通常,上述说明已经足够。这会删除 npm,但会保留你安装的所有东西。
🌐 Usually, the above instructions are sufficient. That will remove npm, but leave behind anything you've installed.
如果这不起作用,或者如果你需要更严厉的措施,请继续阅读。
🌐 If that doesn't work, or if you require more drastic measures, continue reading.
请注意,这仅适用于全局安装的包。本地安装的包完全包含在项目的 node_modules 文件夹中。删除该文件夹,所有内容都会消失,除非某个包的安装脚本行为异常。
🌐 Note that this is only necessary for globally-installed packages. Local installs are completely contained within a project's node_modules folder. Delete that folder, and everything is gone unless a package's install script is particularly ill-behaved.
这假设你在默认位置安装了 node 和 npm。如果你使用不同的 --prefix 配置了 node,或者用不同的前缀设置安装了 npm,那么请相应地调整路径,用你的安装前缀替换 /usr/local。
🌐 This assumes that you installed node and npm in the default place. If you configured node with a different --prefix, or installed npm with a different prefix setting, then adjust the paths accordingly, replacing /usr/local with your install prefix.
要手动删除所有与 npm 相关的内容:
🌐 To remove everything npm-related manually:
rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/npm*
如果你是通过 npm 安装的东西,那么最好的方法是先用 npm 卸载它们,然后在正确安装之后再重新安装。这可以帮助找到任何存在的符号链接:
🌐 If you installed things with npm, then your best bet is to uninstall them with npm first, and then install them again once you have a proper install. This can help find any symlinks that are lying around:
ls -laF /usr/local/{lib/node{,/.npm},bin,share/man} | grep npm
在 0.3 版本之前,npm 对可执行文件和节点模块使用 shim 文件。要追踪这些文件,你可以执行以下操作:
🌐 Prior to version 0.3, npm used shim files for executables and node modules. To track those down, you can do the following:
find /usr/local/{lib/node,bin} -exec grep -l npm \{\} \; ;
🌐 See also