【发布时间】:2020-04-10 17:16:35
【问题描述】:
在发布 nodejs 包时,有些文件会上传到 npm,但不会上传到 Github。为什么?
例如,包是assets-webpack-plugin。
在其package.json 的files 部分中,它包括dist/:
"files": [
"index.js",
"dist/"
],
但在.gitignore 文件中仍然包含dist:
node_modules
dist
tmp
npm-debug.log*
.package.json
# Lock files shouldn't be committed for libraries https://stackoverflow.com/a/40206145
yarn.lock
package-lock.json
问题是为什么 Github 上的项目会忽略这些文件,而 npm 必须包含它们?现在它们在package.json 的files 部分,这意味着这些文件对包很重要——为什么.gitignore 他们?
【问题讨论】:
-
构建工件通常不包含在源代码管理中,因为它们可以从源代码构建。但是,如果您想分发包以供其他人使用,您分发的是构建工件,而不是源代码。
-
同理,游戏下载包含exe文件但不包含源代码,游戏的存储库(git、svn等)包含源代码但不包含exe文件