安装nvm后无法卸载全局npm软件包

Luk*_*_io 15 node.js npm nvm

我找到了几个与此问题相关的线程,但似乎没有一个专门处理我的案例,我一直无法使用我发现的建议来解决.

我跑的时候 npm uninstall -g "some package"

它只是回归:up to date in .043s - 全球一揽子计划仍然存在.

例如,我正在努力uninstall babel-cli,在running npm uninstall -g babel-cli我仍然能够使用之后cli.

这开始在我卸载node,并npm使用重新安装nvm.我想知道我是否在卸载时错过了一些东西node,这导致了问题.我检查了我的点文件,注意到我还有一个.npm外面的.nvm.这是正常的吗?在此先感谢您的任何建议.

LJH*_*arb 29

(nvm维护者在这里)

您可以npm uninstall -g使用的列表npm ls -g --depth=0.如果您没有看到要在那里卸载的东西,但仍然可以访问它,那么如果它是npm-insatlled,它可能与您的系统版本的节点一起安装.

您可以使用快速验证nvm use system && npm ls -g --depth=0.如果您在那里看到包,那么在使用系统版本时,您就可以npm uninstall -g了.

  • 我没有安装系统 npm(只有 nvm)。我可以通过`npm ls -g --depth=0`看到我想卸载的包,但仍然无法卸载它。此外,`npm ls -g --depth=0` 输出:`npm ERR!无效:包列表后的 minizlib@1.0.3 /home/<...>/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/tar/node_modules/minizlib` (3认同)
  • 啊啊 - 在这种情况下,似乎特定节点安装的vpm副本(v8.9.4)已损坏.遗憾的是,最简单的解决方案是卸载该节点版本并重新安装 - "nvm deactivate && nvm uninstall 8.9.4 && nvm install 8.9.4`应该这样做. (3认同)
  • 看起来是这样的。重新安装后一切正常。 (2认同)
  • 神的圣洁母亲。为什么这不是在某处用粗体写的?:D 非常感谢 (2认同)
  • 我使用的是 Macos,自从安装它以来已经很久了 - 不确定。我通过从“/usr/local/bin”中删除命令来修复它 (2认同)

Jam*_*s C 10

抱歉,我知道这是一个老问题,但现在是 2019 年,这对我来说只是一个问题……我发现我需要在 NVM 关心的路径上调用 npm 上的卸载。

以下是对我有用的内容:

Tue Aug 20 08:09:07 ~
<username> $ npm uninstall -g edgemicro@3.0.4
up to date in 0.051s
Tue Aug 20 08:09:13 ~
<username> $ edgemicro --version
current nodejs version is v8.16.0
current edgemicro version is 3.0.4
3.0.4
// Clearly didn’t work :(

// Let’s try sudo ….
Tue Aug 20 08:09:18 ~
<username> $ sudo npm uninstall -g edgemicro@3.0.4
Password:
up to date in 0.035s
Tue Aug 20 08:10:20 ~
<username> $ edgemicro --version
current nodejs version is v8.16.0
current edgemicro version is 3.0.4
3.0.4
// Still didn’t work :(

// So where is this seemingly immortal executable?
Tue Aug 20 08:10:28 ~
<username> $ which edgemicro
/Users/<username>/.nvm/versions/node/v8.16.0/bin/edgemicro
// It’s under some NVM specific path it seems.
// It seems NPM is also under some NVM specific path, kinda expected.
Tue Aug 20 08:10:33 ~
<username> $ which npm
/Users/<username>/.nvm/versions/node/v8.16.0/bin/npm

// So let’s use that exact npm to perform the uninstall …
Tue Aug 20 08:10:42 ~
<username> $ /Users/<username>/.nvm/versions/node/v8.16.0/bin/npm uninstall -g edgemicro
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but npm-shrinkwrap.json was generated for lockfileVersion@0. I'll try to do my best with it!
removed 2442 packages in 25.851s
Tue Aug 20 08:11:24 ~
<username> $ which edgemicro
Tue Aug 20 08:11:29 ~
<username> $ // Done.
Run Code Online (Sandbox Code Playgroud)


Dan*_*oke 7

上述解决方案都不适合我。

我的nvm版本是 1.0.1 - 很奇怪。

所以没有建议:

nvm deactivate && nvm uninstall..
Run Code Online (Sandbox Code Playgroud)

为我工作,因为它们不是命令。

我试图卸载create-react-app

which create-react-app
/usr/local/bin/create-react-app
Run Code Online (Sandbox Code Playgroud)

我只是做了最明显最天真的事情

rm -rf /usr/local/bin/create-react-app
Run Code Online (Sandbox Code Playgroud)

一切都很好!