We have transitioned to yarn on the CI and have seen substantial gain but moving to yarn on development environment will take some time.
Is it possible to sync the existing yarn.lock with package.json? Can yarn upgrade update package.json too?
This is not possible since yarn.lock is not a replacement for package.json. You should see yarn.lock as a replacement for npm-shrinkwrap.json, with which you can manage the exact versions that are actually installed.
If you do a yarn upgrade, it will upgrade the "fixed" dependencies in yarn.lock following the versions (specified with semver) in package.json.
Its not actualy true about yarn.lock - this main problem why we skipped moving to yarn
This is very well explained at this post https://medium.com/@boennemann/avoid-yarn-for-packages-and-fully-enjoy-its-benefits-for-application-development-8bdd4deb33cf
Its not actualy true about yarn.lock
Was this a response to my comment? If so, what part is not true? The article you mentioned only talks about not using the yarn.lock file for _library development_.
@SpaceK33z no - sorry - my bad english :)
I compared the node_modules directories one was created by npm install other by yarn
and got 107 versions mismatch.
diff <(grep \"version\" node_modules/*/package.json -C 0 | sort > node_modules.txt) <(grep \"version\" node_modules_yarn/*/package.json -C 0 | sort > node_modules_yarn.txt)
This worked for me https://www.npmjs.com/package/syncyarnlock
Note for anyone using the syncyarnlock package —_it hardcodes package versions_— for example "demopackage": "^5.0.0", which would normally have an upgrade range including any version in the 5.x.x range becomes _exclusively_ "demopackage": "5.0.1",
@metasean Check option -k, --keepPrefix
Most helpful comment
This worked for me https://www.npmjs.com/package/syncyarnlock