albert albert - 4 months ago 60
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


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

npm prune