I have an project with package-lock.json
file.
Now, I want to generate yarn.lock
file based on package-lock.json
file or existed node_modules
of project.
How can I do this? thanks.
0, Yarn is able to import its dependency tree from npm's package-lock. json natively, without external tools.
All you need to do is issue the yarn import command in a repository with a package-lock. json file, and yarn will use the resolution information from the existing package-lock. json file and a corresponding yarn. lock file will be created.
Keeping your package-lock. json or yarn. lock file will lock in these versions despite allowing for variances in the package. json file.
It is highly recommended you commit the generated package lock to source control: this will allow anyone else on your team, your deployments, your CI/continuous integration, and anyone else who runs npm install in your package source to get the exact same dependency tree that you were developing on.
You can use yarn import to generate yarn.lock
file from an existing npm-installed node_modules
folder.
yarn import
aims to alleviate this challenge by generating a yarn.lock
file in one of two ways:
package-lock.json
file created by npm installnode_modules
according to normal require.resolve()
resolution rules.For example:
☁ api [develop] ⚡ yarn import
yarn import v1.17.3
info found npm package-lock.json, converting to yarn.lock
warning jest > jest-cli > jest-config > jest-environment-jsdom > jsdom > [email protected]: use String.prototype.padStart()
success Saved lockfile.
✨ Done in 21.56s.
You can use the tool synp to convert back and forth:
synp --source-file yarn.lock # will create package-lock.json
synp --source-file package-lock.json # will create yarn.lock
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With