Reputation: 102237
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.
Upvotes: 37
Views: 26863
Reputation: 102237
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.
Upvotes: 72
Reputation: 28180
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
Upvotes: 7
Reputation: 210
as of yarn 1.7.0 (2018-06-04) you can use yarn import
to convert npm package-lock.json to yarn.lock instead of having to npm install
first for node_modules and tell yarn to take a looks at that
https://yarnpkg.com/lang/en/docs/migrating-from-npm/
https://yarnpkg.com/blog/2018/06/04/yarn-import-package-lock/
Upvotes: 0