簡體   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