how to convert package-lock.json to yarn.lock?
12,688
Solution 1
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:
- Using the dependency tree in an existing
package-lock.json
file created by npm install - If no such file exists, using the versions found inside
node_modules
according to normalrequire.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.
Solution 2
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
![slideshowp2](https://i.stack.imgur.com/g22sX.jpg?s=256&g=1)
Author by
slideshowp2
Keep coding until the earth blows up... Solve problems, don't create them, and don't hide them SO-driven & TDD-driven programming learning
Updated on June 05, 2022Comments
-
slideshowp2 about 2 years
I have an project with
package-lock.json
file.Now, I want to generate
yarn.lock
file based onpackage-lock.json
file or existednode_modules
of project.How can I do this? thanks.