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
393 views
in Technique[技术] by (71.8m points)

node.js - Should package-lock.json also be published?

npm 5 introduced package-lock.json, of which the documentation is here.

It states that the file is intended to be included with version control, so anyone cloning your package and installing it will have the same dependency versions. In other words, you should not add it to your .gitignore file.

What it does not state is wether or not the file is intended to be included with a published package. This question could be rephrased as; should package-lock.json be included in .npmignore?

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

It cannot be published.

From the npm documentation:

One key detail about package-lock.json is that it cannot be published, and it will be ignored if found in any place other than the toplevel package

See package-lock.json documentation on docs.npmjs.com.

However, you should be commiting your package-lock.json to git as per the documentation.

This file is intended to be committed into source repositories

hence the common message presented by npm:

created a lockfile as package-lock.json. You should commit this file.

EDIT: A more detailed explanation can be found here.


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

...