Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
362 views
in Technique[技术] by (71.8m points)

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

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.

question from:https://stackoverflow.com/questions/65831450/difference-between-package-lock-and-node-modules-package-lock

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...