How to uninstall global package with npm?

node.jsNpmWebpack

node.js Problem Overview


I have installed webpack in this way:

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:

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:

npm uninstall webpack
npm WARN babel-loader@6.4.1 requires a peer of webpack@1 || 2 || ^2.1.0-beta || ^2.2.0-rc but none was installed.
npm WARN uglifyjs-webpack-plugin@0.3.1 requires a peer of uglify-js@^2.8.0 but none was installed.
npm WARN uglifyjs-webpack-plugin@0.3.1 requires a peer of webpack@^1.9 || ^2 || ^2.1.0-beta || ^2.2.0-rc but none was installed.

node.js Solutions


Solution 1 - node.js

Try running both of the below commands:

npm uninstall -g webpack
npm uninstall webpack

I think you might be checking/looking at the local version after deleting only the global one.

Solution 2 - node.js

You have to remove the packages manually installed globally on your os with sudo:

On OsX navigate to this directory

cd /usr/local/lib/node_modules

and

sudo rm -rf <packageName> // sudo rm -rf webpack

Solution 3 - node.js

npm uninstall -g webpack

Worked for me, try running the command prompt in administrator mode.

Solution 4 - node.js

You're most likely running a file from another install of npm.

Run which webpack to see where your shell is finding webpack.

Run npm root -g to find the root of the tree it's supposed to be in, being sure you're running the correct npm with npm -v and which npm.

If your webpack bin isn't in the npm root, reset your path to the webpack binary e.g. hash -d webpack in bash, and then go remove the unwanted npm root from your PATH variable. You can now use npm install -g webpack and npm uninstall -g webpack and it should work.

Solution 5 - node.js

I have tried uninstalling global packages in several ways.

npm uninstall -g <package_name> this didn't work.

I managed to remove the global packages in the following way:

  • Goto terminal
  • Run this command npm list -g
  • Goto the path (C:\Users\user\AppData\Roaming\npm)
  • Delete all the related files to your package
  • Goto node_modules find and delete the package

This should work.

YW!

Solution 6 - node.js

Try

chown -R "$(whoami)": "$(npm root -g)" 

(you may need sudo for it) and then npm uninstall -g again

Solution 7 - node.js

If you are using Node Version Manager (nvm) and you want to remove a global system package you will need to switch to that version. For example:

nvm use system
npm uninstall -g webpack

Solution 8 - node.js

on windows run as administrator and run the command

npm uninstall -g webpack

on Linux

sudo npm uninstall -g webpack

Solution 9 - node.js

In Windows, open the cmd with Administrator rights (start -> type cmd -> right-click on icon -> open with adm. rights), then navigate (in cmd type "cd ../../users/your_user_name") to your user folder, then run

npm uninstall -g webpack

or (I don't remember which one worked for me)

npm uninstall webpack

Solution 10 - node.js

Had the same issue an none of the answer above helped.

My project was in a sub-directory of a larger project, which also had a node_modules folder.

That's why it says, something like "found another version higher in the tree."

Delete that folder, go back to your sub-dir, remove node_modules and package-lock.json, and finally run npm install again.

Solution 11 - node.js

In archlinux, after running

> npm uninstall -g <package_name>

you might have to manually enter /usr/lib/node_modules/ to remove the package's directory. This will prevent conflicts if you try reinstalling that package with a different package manager like pacman.

Solution 12 - node.js

Try This:

npm uninstall -g <package_name> 
E.g: npm uninstall -g webpack

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questioncloud_cloudView Question on Stackoverflow
Solution 1 - node.jsSujithView Answer on Stackoverflow
Solution 2 - node.jskarthik006View Answer on Stackoverflow
Solution 3 - node.jsBenjamin RobertsView Answer on Stackoverflow
Solution 4 - node.jsSamuel DanielsonView Answer on Stackoverflow
Solution 5 - node.jscsgeekView Answer on Stackoverflow
Solution 6 - node.jsuser8012147View Answer on Stackoverflow
Solution 7 - node.jsDavidView Answer on Stackoverflow
Solution 8 - node.jsMD SHAYONView Answer on Stackoverflow
Solution 9 - node.jsIhorView Answer on Stackoverflow
Solution 10 - node.jsSaltyCatFishView Answer on Stackoverflow
Solution 11 - node.jsRomeo FolieView Answer on Stackoverflow
Solution 12 - node.jsRafiqul IslamView Answer on Stackoverflow