繁体   English   中英

Npm 和 git 需要发布“node_modules”(依赖项)?

[英]Npm and git need to publish “node_modules” (dependencies)?

我对在 npm 和 git 上发布的良好做法有疑问。

我有一些 package 需要(具有依赖关系)模块(例如:引导程序)。

When I create my package.json with the method of "npm install bootstrap" it's creating a nodes_modules with bootstrap in my directory, but if I just put "dependencies bootstrap" inside the package.json without do a "npm install bootstrap" it's not创建“nodes_modules”。

In the two case, after I publish my package (with npm publish), when I install the package on my prod application the "dependencies" call "bootstrap" normaly (with or without my "nodes_modules" where I had create the package). 所以我的第一个问题是,我不明白用“nodes_modules”发布我的 package 是否更好? (因为在实践中这两种情况都有效..)

Also if I choose to publish my package with "nodes_modules", after I want to commit my package and push it with git, but it's create the "nodes_modules" and "package-lock.json" on my github repositories. 所以我的第二个问题是:在 github 上保留“nodes_modules”和“package-lock.json”是个好习惯吗? 还是最好忽略它们?

谢谢你的帮助

你不应该在你的 repo 中包含node_modules或发布它。

您应该在您的存储库中包含package.json并发布它; 我看不出您如何避免这种情况,因为这是您分发的 package 的基本描述。

根据文档,您应该将包锁定文件签入源代码管理,但它没有发布。 我觉得这种用法很奇怪,但它似乎是预期的用法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM