node.js 如何使用 npm 卸载全局包?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44962349/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to uninstall global package with npm?
提问by cloud_cloud
I have installed webpack in this way:
我以这种方式安装了 webpack:
npm install -g webpack
Now want to uninstall it:
现在想卸载它:
npm uninstall -g webpack
Check it again, it didn't been uninstalled:
再次检查,它没有被卸载:
webpack -v
3.1.0
Why?
为什么?
And, I use this way can't find webpack:
而且,我用这种方式找不到webpack:
npm list -g | grep webpack
This also didn't work:
这也不起作用:
npm uninstall -g webpack --save
After run this under a directory which included package.json:
在包含以下内容的目录下运行此命令后package.json:
npm uninstall webpack
npm WARN [email protected] requires a peer of webpack@1 || 2 || ^2.1.0-beta || ^2.2.0-rc but none was installed.
npm WARN [email protected] requires a peer of uglify-js@^2.8.0 but none was installed.
npm WARN [email protected] requires a peer of webpack@^1.9 || ^2 || ^2.1.0-beta || ^2.2.0-rc but none was installed.
回答by Sujith
Try running both the below:
尝试运行以下两个:
npm uninstall -g webpack
npm uninstall webpack
I think you might be checking/lloking at the local version after deleting only the global one.
我认为您可能会在仅删除全局版本后检查/查看本地版本。
回答by Benjamin Roberts
npm uninstall -g webpack
Worked for me, try running the command prompt in administrator mode.
对我来说有效,尝试在管理员模式下运行命令提示符。
回答by Benjamin Roberts
Try
尝试
chown -R "$(whoami)": "$(npm root -g)"
(you may need sudo for it) and then npm uninstall -g again
(您可能需要 sudo)然后再次 npm uninstall -g
回答by Samuel Danielson
You're most likely running a file from another install of npm.
您很可能正在运行另一个 npm 安装中的文件。
Run which webpackto see where your shell is finding webpack.
运行which webpack以查看您的 shell 在哪里找到 webpack。
Run npm root -gto find the root of the tree it's supposed to be in, being sure you're running the correct npm with npm -vand which npm.
运行npm root -g以找到它应该在的树的根,确保你正在运行正确的 npmnpm -v和which npm。
If your webpack bin isn't in the npm root, reset your path to the webpack binary e.g. hash -d webpackin bash, and then go remove the unwanted npm root from your PATH variable. You can now use npm install -g webpackand npm uninstall -g webpackand it should work.
如果您的 webpack bin 不在 npm root 中,请重置 webpack 二进制文件的路径,例如hash -d webpack在 bash 中,然后从 PATH 变量中删除不需要的 npm root。您现在可以使用npm install -g webpack和npm uninstall -g webpack它应该工作。
回答by karthik006
You have to remove the packages manually installed globally on your os with sudo:
您必须使用 sudo 删除在您的操作系统上全局手动安装的软件包:
On OsX navigate to this directory
在 OSX 上导航到此目录
cd /usr/local/lib/node_modules
and
和
sudo rm -rf <packageName> // sudo rm -rf webpack

