0

When installing npm libraries, If I overwrite one of them by using @latest, or simply @1.2.0, @5.4.3...is there a way to know what versions had been installed prior to installing the newer versions?

I have encountered a problem in a latest version of a library, and I've been trying to check many versions to see if it would work, but none of them do.

I'm trying to figure out what version number I had before all my tries.

RobC
  • 22,977
  • 20
  • 73
  • 80
Germán
  • 1,007
  • 1
  • 7
  • 20
  • Does this answer your question? [Find the version of an installed npm package](https://stackoverflow.com/questions/10972176/find-the-version-of-an-installed-npm-package) – RobC Feb 27 '20 at 10:30
  • It seems it just returns the installed version. – Germán Feb 27 '20 at 10:36
  • What I would need is something like a control of versions installed from the very beginning of installations. – Germán Feb 27 '20 at 10:44
  • 1
    Well, you did say, _"is there a way to know what versions have been installed?"_ however I missed the part in question that read _"I'm trying to figure out what version number I had before all my tries"_. The short answer is _"No"_ npm has no built feature. If retrospectively you had run something like `npm list --json > ./path/to/before.json` before installing new version(s). Then after installing new version(s) of package(s) you could have run `npm list --json > ./path/to/after.json`. Then diff the two file (before.json, and after.json) to check what changed. – RobC Feb 27 '20 at 10:45
  • I suggest you consider using of a [npm lockfile](https://docs.npmjs.com/files/package-locks) (`package-lock.json` / `npm-shrinkwrap.json`) in the future to negate this kind of scenario from happening again. If you had committed a lockfile to your VCS (e.g. git) it will provide a means to; _diff_ changes (before and after install updates), and restore the exact same node_modules tree when problems occur. – RobC Feb 27 '20 at 11:06

0 Answers0