How can I uninstall npm
modules with devDependencies in Node.js?
-
2Possible duplicate of [How to uninstall npm modules in node js?](https://stackoverflow.com/questions/13066532/how-to-uninstall-npm-modules-in-node-js) – TGrif May 26 '19 at 16:31
-
4Unless he is looking for `npm prune --production`. Maybe add this as a fifth point to your list? – gwest7 Feb 10 '21 at 09:05
2 Answers
Use command:
1)npm uninstall <name of the module>
Also you can use:
1) npm uninstall <name of the module>
: to remove the module from node_modules, but not package.json
2) npm uninstall <name of the module> --save
: to also remove it from dependencies in package.json
3) npm uninstall <name of the module> --save-dev
: to also remove it from devDependencies in package.json
4) npm -g uninstall <name of the module> --save
: to remove it globally

- 4,883
- 2
- 13
- 35
-
I was new to this npm thing and these commands helped me to solved my issue. Great Job! – Vishesh Apr 16 '21 at 17:41
For dev dependencies you can preform one -of- two commands, depending on your situation.
- If you simply want to remove the dependency you can use the following.
npm rm name-of-dependency
TIP: If you forget how the name was spelled, check your package.json
file under "devDependencies"
.
- If you installed the dependency as a "dev-dependency", and you decided after the fact that you wanted it installed as a regular "dependency" then you can simply install it using the
-S
flag, as shown below:npm i -S name-of-dependency
TIP: It also works the other way around. To move a dependancy from the "dependencies" field in your package.json
file, to the "devDependencies"
field, swap out the -S
flag for the -D
flag.
The install command i
and the rm
command (also the -S
and -D
flags) are currently the method that NPM uses to document the process for removing packages, and or changing a packages dependency type.
SEE MORE ABOUT NPM CLI COMMANDS FOR INSTALLING & REMOVING PACKAGES HERE

- 8,532
- 3
- 51
- 77