Lin Du
Lin Du

Reputation: 102457

How to convert npm-shrinkwrap.json to package-lock.json file?

I have an old project with npm-shrinkwrap.json file.

Now, I want to convert npm-shrinkwrap.json to package-lock.json file.

How can I do that?

The most important thing is the dependency tree and version must be correct.

Upvotes: 10

Views: 1948

Answers (1)

Chintan Mangukiya
Chintan Mangukiya

Reputation: 161

As a simple solution, we may just rename file from npm-shrinkwrap.json to package-lock.json since both the files are meant to have exactly same content and format. Done! Refs package-lock.json and npm-shrinkwrap.json.

Although both the files have exactly the same content, there are a handful of differences in how npm handles them. For example when we run npm install vs npm ci commands. Also note that package-lock.json will not be published to npm registry unlike npm-shrinkwrap.json, if we ever decide to publish our npm package (using npm publish command). One may refer official npm docs for detailed info on these specific commands.

Cheers!

Upvotes: 7

Related Questions