I ran npm install
to a project and faced multiple errors due to updated dependencies. Is there a way I can undo it and retrieve my previous node_modules
folder and files?

- 6,157
- 8
- 47
- 80
-
1you can change version of packages in package.json – GokulnathP Mar 08 '21 at 05:04
1 Answers
If you ran the command npm install
in a directory, the expected behavior is to update your node_modules
to match the dependencies described in package.json
file, if it exists. See the npm docs.
You'd like to revert to your older module versions specifically. If you've been committing your project's files with Git (or another version control system), you could look at previous commits to see your old dependencies, in the old package.json
file.
If not, most file systems don't offer an "undo" or "revert" system for edited files, such as updated modules. Sorry!
But if you're having problems when you install everything in package.json
, you may want to edit that file so npm install
can be used and not throw errors. You can edit the saved version of an npm dependency in the command line, like this: npm install <package>@<version>
. Here's a reference on manually updating dependency versions. Good luck!

- 11
- 2