Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between package-lock and node_modules/.package-lock

Tags:

node.js

npm

What's the purpose of the additional .package-lock.json inside node_modules? It seems to be a subset of package-lock.json.

I assume this has been asked before, but i couldn't find anything in the npm docs, and google still refuses to properly search for punctuation symbols, so here we are.

PS: It's recreated by npm i, when i delete it. However i cannot find it on older projects of mine, so it appears to be a newer thing.

like image 858
Doofus Avatar asked Jun 22 '26 11:06

Doofus


1 Answers

The additional node_modules/.package-lock.json is a helper file, which speeds up npm under normal circumstances. When npm finds, that node_modules hasn't changed (checked by e.g. looking at the modified-time of package folders), it can be used instead of processing the folder repeatedly.

As RobC mentions in his comment:

A comprehensive description for node_modules/.package-lock.json can be found in the Hidden Lockfiles section of the "yet to be published docs" in the GitHub repo.

like image 69
Doofus Avatar answered Jun 25 '26 02:06

Doofus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!