extract-exact-versions

This repository is a Node.js utility to replace the version ranges in the package.json file with exact version numbers of each package from the package-lock.json file. This helps with migration into the save-exact way of storing packages in the package.json files.

This project only works for npm - the default package manager for Node.js projects. Other package managers - like yarn, pnpm, bun, etc. are not supported yet.

Usage

To use:

  1. Clone this repository.
  2. Switch to Node.js as mentioned in the .nvmrc file.
    • This Node.js version is necessary to run the current repository.
    • However, the project can parse package.json and package-lock.json files generated by npm versions 6 through 10 (and maybe higher versions not released yet).
  3. Copy the following files from your Node.js projects into the input folder:
    1. package.json
    2. package-lock.json
    3. Note: The files in the input folder have been ignored from git. So unless you remove the git configuration, you can't accidentally commit these files into this project.
  4. Run npm start at the root of the project.
  5. If everything goes as expected, a package.output.json file should have been generated in the output folder.
    1. You should be able to safely copy the contents from this file into the package.json file of your project.