aug aug - 2 months ago 48
Node.js Question

How to undo npm update?

Is there a way to undo the command

npm update
? I ran the command and now I have a bunch of unmet dependencies and some errors.

I'm trying to manually reinstall and fix all the errors but does anyone know how to essentially revert an
npm update
?

Answer

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).

Comments