Is it possible to generate a `yarn.lock` file without installing the packages?

EDIT: Please check the comment below for a solution without the need for any additional package thanks to @talon55 : npm install --package-lock-only; yarn import

Old answer:

This is actually one of the few features that NPM has (npm install --package-lock-only) and Yarn does not support.

It is a heavily requested feature as you can tell from these 2 open Github issues: 5738 and 2340

I stumbled upon the command yarn generate-lock-entry documented in here but it definitely does not do what we are looking for.

The workaround I would suggest is generating an NPM lock file and converting it to a yarn.lock file using synp:

npm install -g synp
npm install --package-lock-only
synp --source-file package-lock.json

Please note that Synp requires the the packages to be installed and that the node_modules is rightly populated. This may, or may not be, a problem to your use case.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)