Albert Lazaro de Lara
Albert Lazaro de Lara

Reputation: 2710

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?

Upvotes: 4

Views: 5242

Answers (1)

Sahil Shaikh
Sahil Shaikh

Reputation: 171

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

npm prune

Upvotes: 6

Related Questions