How to remove npm package?

I installed grunt using sudo npm install grunt and I cannot remove it.

I tried:

 $ sudo npm uninstall grunt 

but it gives WARN:

 npm WARN uninstall not installed in /home/kuba/projects/node_modules: "grunt-cli" 

I am also trying to execute rm, delete and unlink. and -g , it gives:

 npm WARN uninstall not installed in /usr/lib/node_modules: "grunt" 

but I can still call grunt from the command line.

EDIT

 $ whereis grunt grunt: /usr/local/bin/grunt $ file /usr/local/bin/grunt /usr/local/bin/grunt: symbolic link to `../lib/node_modules/grunt/bin/grunt' $ ls /usr/local/lib/node_modules grunt jshint $ ls /usr/lib/node_modules bower csslint devtools-terminal npm plato 

Why do I have 2 directories with npm? Can I just delete it?

+50
npm gruntjs uninstall
Mar 25 '14 at 17:58
source share
4 answers

To remove the npm module from the node_modules project node_modules , run:

npm uninstall <module> --save

Note that when executing this command, npm modules must be removed from the same directory as the node_modules folder. The --save option --save also remove it from package.json

You can also remove the local dependency / module installation by removing its directory from the local node_modules folder. Yes, it’s safe to remove dependencies there.

To remove the npm module that was installed globally, run:

npm uninstall -g <module>

It doesn't matter where you run this command from.

To install the npm module, run: (as a reference only)

npm install <module>

... or:

npm install (if the package.json file is in the root directory of your project)

... or:

npm install <module> --save-dev (if you want to add a minimal version to the dependency)

Good things to learn about Grunt :

  • If you installed grunt stable before February 18, 2013 ( grunt v0.4.x was released ), you may have an older grunt version still stored on your system. This is because grunt versions below 0.4.x were installed globally, which caused great pain when updating / saving versions.
  • grunt and grunt-cli are two different things.

    • grunt (without "cli") is usually installed at the project level (when specifying devDependency in package.json ) by running npm install . This is also known as a local installation.
    • grunt-cli is the basic framework on which local versions of grunt run in different projects / folders. It can be installed locally, but is more useful if it is installed globally once.
  • grunt installs only locally (by running npm install grunt ).

  • grunt-cli preferably installed globally (by running npm install -g grunt-cli ). grunt-cli The official npm page still warns about installing grunt (without cli) worldwide.
  • If you want to uninstall the global grunt-cli , run npm uninstall -g grunt-cli . This issue in gruntjs supports this procedure.
  • Never install grunt globally (by running npm install -g grunt ).

On npm and sudo

sudo does not work well with npm . Use it only if necessary. Below are two quotes about the advantages and disadvantages of using it:

A quote from Isaac Z. Schluter about his Introduction to npm :

I highly recommend that you do not manage packages with sudo! Packages can run arbitrary scripts, which makes court management a package manager team as safe as a chainsaw haircut. Of course, he’s going to quickly and definitely cut through any obstacles, but you might really want this obstacle to remain there.

I recommend doing this once:

sudo chown -R $USER /usr/local

This sets up the user account as the owner of the / usr / local directory, so you can just issue the usual commands there. Then you will never have to use sudo when you install node or run npm commands.

This is much better. / Usr / local is assumed to be the material you installed.

Another catch mentioned by Andrey Karpushonak :

There are certain security problems and functionality limitations regarding the change of ownership of / usr / local for the current user:

Having said that, if you want to install a global module without using sudo, I do not see a better solution (from a pragmatic point of view) than mentioned. Safety and ease of use is a very broad topic, and there is no simple answer to this question. - it just depends on your requirements.

+89
Mar 25 '14 at 23:02
source share

The same thing happened to me. While doing

 which grunt 

I got path / usr / local / bin /. Inside was a folder. But when you run the command (even from within the / usr / local / bin / path):

 sudo npm uninstall -g grunt 

A warning is being set. Not installed.

Solution: it turns out that I installed using the command

 sudo npm install -g grunt-cli 

And when trying to remove it was just typing grunt

So, as soon as I started

 sudo npm unistall -g grunt-cli 

grunt removed.

Although you mentioned that you run

 sudo npm install grunt 

But still check if you are executing the same error and run it with grunt-cli

+4
Jan 29 '16 at 11:55
source share

In some cases, you may need to use the npm function "remove package".

npm - Remove package

Description

"This removes the package, completely removing all npm installed on its behalf."

On your third block of code, you sent this message:

 npm WARN uninstall not installed in /home/kuba/projects/node_modules: "grunt-cli" 

I found that using

 which grunt 

or

 whereis grunt 
Teams

CLIs provide incomplete and confusing output.

Both of these commands will return the path to installing grunt-cli , but return it simply as grunt .

Also using

 which grunt-cli 

or

 whereis grunt-cli 

Unable to return any output to the CLI console. I believe this is a namespace issue / function with npm.

I also had a situation where I was not able to uninstall grunt-cli with the npm removal function, as recommended by other participants above.

The only thing that worked for me was to use the npm remove function with the full name of the program , as shown below.

 npm rm -g grunt-cli 

This should return the following to the console.

 unbuild grunt-cli@#.##.# 

Good luck

+1
Jul 20 '15 at 21:10
source share

Use this first

 which grunt-cli

Or

 which grunt

And this will show you the path to the module

In my case, it was in the / usr / local / bin / directory

As soon as I got to the bin folder, I just wrote

 sudo rm grunt

And that was the end of it :)

+1
Aug 27 '15 at 9:32
source share



All Articles