卸载 npm 包后出错

Error after uninstalling npm packages

我已经使用以下命令卸载了 npm 包 'grunt-cli' 和 'tsd':

sudo npm uninstall -g grunt-cli 
sudo npm uninstall -g tsd

但是现在,当我列出所有 npm 包时:

npm -g ls --depth=0

我收到这个错误。没有这样的文件或目录。这是正确的,因为我刚刚卸载了它们...

/usr/local/lib
├── bower@1.7.1
├── browserify@12.0.1
├── express-generator@4.13.1
├──  error: ENOENT: no such file or directory, open '/usr/local/lib/node_modules/grunt-cli/package.json
├── npm@3.5.3
├──  error: ENOENT: no such file or directory, open '/usr/local/lib/node_modules/tsd/package.json
└── typescript@1.8.9

为什么会出现此错误?如何完全删除 grunt-cli 和 tsd? ENOENT 是什么意思? (尝试用谷歌搜索...)

使用which grunt-cli找到g运行t-cli文件夹然后运行sudo rm grunt-cli

对 tsd 做同样的事情。

尽管有你 运行 npm uninstall 命令,但以下目录可能仍然意外存在。

  • /usr/local/lib/node_modules/grunt-cli
  • /usr/local/lib/node_modules/tsd

在这种情况下,您需要通过rm -r命令手动删除它们:

$ rm -r /usr/local/lib/node_modules/tsd
$ rm -r /usr/local/lib/node_modules/grunt-cli

此外,您应该检查命令别名是否仍然存在。命令名称是 tsd and grunt,检查并删除它们(如果存在)。

$ which tsd <= check command path
/usr/local/bin/tsd <= if it exist
$ rm /usr/local/bin/tsd <= remove it

$ which grunt <= check command path
/usr/local/bin/grunt <= if it exist
$ rm /usr/local/bin/grunt <= remove it