Update package.json and record version range

The dependencies in package.json were added as latest.
If it is latest, the latest package is always taken, so specify the version at the time of development.

目次

Update package.json to specify the version.

Use the syncyarnlock command.
The -h option can be used for help.

$ npx syncyarnlock -h   
Usage: syncyarnlock [options]

Sync `yarn.lock` package versions, into package.json

Options:
  -V, --version                  output the version number
  -d, --dir <path>               directory path where the yarn.lock file is located (default to current directory)
  -p, --dirPackageJson <path>    directory of project with target package.json, if not set, -d will be used
  -s, --save                     By default don't override the package.json file, make a new one instead package.json.yarn 
  -k, --keepPrefix               By default the ^ or any other dynamic numbers are removed and replaced with static ones.
  -g, --keepGit                  By default direct git repositories are also replaced by the version written in yarn.
  -l, --keepLink                 By default direct link: repositories are also replaced by the version written in yarn.
  -a, --keepVariable <variable>  By default everything is converted to yarn version, write a part of the type you wish not to convert, seperate by comma if more than one, to not replace git and link you would use +,link:
  -h, --help                     output usage information

Update package.json with -s.
Replace with static version specification with -k.

$ npx syncyarnlock -s -k

When you run this command, you will get a message asking if it is OK to process, enter ‘y’ and enter.

$ npx syncyarnlock -s -k
Need to install the following packages:
  syncyarnlock@1.0.19
Ok to proceed? (y) 

If you get the following message, you have succeeded.

Saved /package.json 

Summary

In this way, what was specified as LATEST can be changed to the current version specification.

よかったらシェアしてね!
目次