Is there a command to remove all global npm modules? If not, what do you suggest?
相关问题
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- google-drive can't get push notifications
- Failed at the electron@1.8.2 postinstall script
- How to reimport module with ES6 import
- Webpack getting started, import error
相关文章
- node连接远程oracle报错
- How can make folder with Firebase Cloud Functions
- @angular-cli install fails with deprecated request
- node.js modify file data stream?
- How to resolve hostname to an ip address in node j
- Transactionally writing files in Node.js
- Log to node console or debug during webpack build
- Get file created date in node
Just switch into your
%appdata%/npm
directory and run the following...EDIT: This command breaks with npm 3.3.6 (Node 5.0). I'm now using the following Bash command, which I've mapped to npm_uninstall_all in my .bashrc file:
Added bonus? it's way faster!
https://github.com/npm/npm/issues/10187
How do you uninstall all dependencies listed in package.json (NPM)?
I tried Kai Sternad's solution but it seemed imperfect to me. There was a lot of special symbols left after the last
awk
from the deps tree itself.So, I came up with my own modification of Kai Sternad's solution (with a little help from cashmere's idea):
npm ls -gp --depth=0
lists all globally-installed npm modules in parsable format:awk -F/node_modules/ '{print $2}'
extracts module names from paths, forming the list of all globally-installed modules.grep -vE '^(npm|)$'
removes npm itself and blank lines.xargs -r npm -g rm
callsnpm -g rm
for each module in the list.Like Kai Sternad's solution, it'll only work under *nix.
in windows use "C:\Users\username\AppData\Roaming" path and manually remove npm folder
Use this code to uninstall any package: