How to undo npm update?

You can restore your package.json file to its previous state (hopefully you still have that, or at least remember what you had changed), and then do another npm update.

[UPDATE]

However, in general, this technique does not guarantee that your entire dependency tree will be restored to its exact former state (since the package.json files in a dependency tree often loosely specify dependency versions).

If you need to ensure that your package's dependency tree can be restored exactly, you have to use something like npm shrinkwrap to "lock down" the dependency versions (before you publish the package).


Do this:

git log

then Copy the latest latest key. This will let you checkout your latest commit.

git checkout "your-key" package.json
git checkout "your-key" package-lock.json 

without the " quotes

(package-lock.json is really necessary, but I like to do et anyway - "Just to make sure...")

you can do a

git status

to make sure that your package.json and package.lock

You can also do the

rm -rf node_modules/ 

which will delete node_modules folder

npm install

All I did was to do "rm -rf node_modules" to uninstall the updated node_modules and then "npm install" to reinstall them; my package.json hadn't change when I did npm update which caused all the havoc. So by deleting and reinstalling node_modules I'm gladly back in business.

Tags:

Node.Js

Npm