How to undo an npm update?

Is there any way to cancel the npm update command? I executed the command and now I have a bunch of unsatisfied dependencies and some errors.

I am trying to manually reinstall and fix all errors, but does anyone know how to essentially return npm update ?

+6
source share
2 answers

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

[UPDATE]

However, in general, this method does not guarantee that your dependency tree will be restored to its previous state (since package.json files in the dependency tree often freely indicate the version of the dependency).

If you need to make sure that the package dependency tree can be accurately restored, you should use something like npm shrinkwrap to โ€œblockโ€ the version of the dependencies (before publishing the package).

+5
source

All I did was do โ€œrm -rf node_modulesโ€ to remove the updated node_modules, and then โ€œnpm installโ€ to reinstall them; my .json package did not change when I updated npm, which caused all the chaos. Therefore, having uninstalled and reinstalled node_modules, I will gladly return to business.

0
source

Source: https://habr.com/ru/post/981028/


All Articles