卸载npm包

时间:2016-04-07 13:36:10

标签: npm npm-install

我使用以下命令卸载了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是什么意思? (尝试谷歌搜索...)

2 个答案:

答案 0 :(得分:4)

尽管您运行了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

此外,您应该检查命令别名是否仍然存在。命令名称是 tsdgrunt,只需检查并删除它们即可。

$ 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

答案 1 :(得分:1)

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

为tsd做同样的事。

相关问题