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 :
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.