150

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 [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.
7
  • stackoverflow.com/questions/13066532/… Commented Jul 7, 2017 at 4:07
  • @Sujith npm uninstall -g webpack --save also didn't work. Commented Jul 7, 2017 at 4:13
  • Do you have a webpack local version installed along with global? Try running "npm uninstall webpack" . I think you might have deleted it the global version and trying to check the local webpack version Commented Jul 7, 2017 at 4:21
  • Often when people install globally they use sudo. If so, you'd have to use sudo npm uninstall -g webpack, too. Commented Jul 3, 2018 at 19:01
  • 2
    You ever get this solved? Commented Jan 30, 2019 at 15:36

15 Answers 15

111

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I did that. Then got new errors. Put them to the bellow of question.
I had to remove manually the folder and the symlink, npm uninstall -g would not do it for some reason. whereis <package> can help locate the folder.
30

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

3 Comments

More generally, run which <packageName>. Then run rm -rf on the directory/file that makes sense (maybe there's a root directory or you get an alias file which references the main binary, which you may notice when running ls -l $(which <packageNameAlias>), in which case, you might want to delete both the original binary file and the alias). YMMV.
I also had to manually delete it like this on Ubuntu.
Confirming this works. Looks like after installing nvm, the program didn't move all my global scripts from local to .nvm folders where specific node versions live
16

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!

1 Comment

THE BEST OPTION! npm has gone haywire with versions. It's version hell now days.
13
npm uninstall -g webpack

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

Comments

9

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.

Comments

7

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

1 Comment

Thanks for the shortcut to change back to the system version - I always ended up looking in my distro to see the current system version number!
2

Try

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

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

1 Comment

I even as a root user now. I have tried your way, but the same result. The 3.1.0 of webpack also exists.
1

on windows run as administrator and run the command

npm uninstall -g webpack

on Linux

sudo npm uninstall -g webpack

Comments

1

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

Comments

0

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.

Comments

0

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.

Comments

0

Building on @karthik006 's answer of deleting directly from the global node_module folder, if you are using nvm, you first need to decide from which version of node you want to delete the global package.

After that, switch to that version of node using nvm use <version>

Then run nvm which current to get the path where the executable for this version of node is saved.
The path will be something like <path to nvm node dir>/<node version>/bin/node

Using this path, cd into <path to nvm node dir>/<node version>/lib/node_modules and then rm -rf the packages that you want to remove.

Comments

0

On ubuntu the package I was on the hunt for was buried in ~/.npm/_npx/<chars>/node_modules/ and in ~/.npm/_npx/<chars>/node_modules/.bin/. I removed the bin and the directory and got the reinstall prompt.

Comments

0

For Linux users, after npm uninstall -g <package_name>, check in your home directory if there is any folder with this package name.

Using the locate and find commands, I have noticed that some globally installed packages create extra folders in home directory. Remove them as well rm -rf ~/.<package_name>/

Comments

-1

Try This:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.