1

I would like to display all my installed npm packages (nodemailer, json, etc) and delete them. Also, I would like to clean npm "history".

I have read that I should do this: npm list -g to display all packages but I am not sure this is exactly it because I have recently downloaded nodemailer and it is not in this list...

Any help? Thanks!

1 Answers1

0

Try this:- it removes all global npm modules. Note: this does not work on Windows.

npm ls -gp --depth=0 | awk -F/ '/node_modules/ && !/\/npm$/ {print $NF}' | xargs npm -g rm

For Windows in a directory

refer this medim article to delete node modules in a folder

if this doesn't work for you refer this https://stackoverflow.com/questions/9283472/command-to-remove-all-npm-modules-globally#:~:text=If%20you%20would%20like%20to,g%20rm%20to%20remove%20them.

Jatin Mehrotra
  • 9,286
  • 4
  • 28
  • 67
  • I have windows... Anyway, I actually would like to delete packages in this directory: npm list --depth –  Aug 31 '20 at 15:03
  • i have updated my answer for windows( to delete for a particular folder) and that stack link have answer for windows too :) – Jatin Mehrotra Aug 31 '20 at 15:09