albert albert - 1 year ago 121
Node.js Question

NPM: revert installed packages

I'm working in a Node.js application with npm and git. When I add new npm packages I use

npm <package> --save
and it is saved on 'package.json' file.

The thing is that when I use
git reset --hard
, the 'package.json' file is reverted, but the packages are still installed.

The question is: how can I uninstall automatically npm packages that I have installed before the
git reset --hard

Answer Source

After reverting, you can try npm prune option. This will unbuild all the packages not there in package.json

npm prune
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download