0

Suppose I read a package.json file in as a string/json object. is it possible to create a package-lock.json file programmatically?

for example, something like this:

const pkg = require('./package.json');
const pkgLock = generatePackageLock(pkg);

does anything like this exist or do I HAVE to use the npm cli to do this?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Ben
  • 16,124
  • 22
  • 77
  • 122

1 Answers1

0

Based on the docs provided by npm, I don’t think it’s possible to create it programmatically.

This is what npm doc says

‘package-lock.json is automatically generated for any operations where npm modifies either the node_modules tree, or package.json. ‘

https://docs.npmjs.com/files/package-lock.json

Johnson Samuel
  • 2,046
  • 2
  • 18
  • 29