应该“node_modules”文件夹被包含在git仓库中 [英] Should "node_modules" folder be included in the git repository

查看:95
本文介绍了应该“node_modules”文件夹被包含在git仓库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否应该在我们的repo中跟踪node_modules,或者在检查代码时执行npm install?

I'm wondering if we should be tracking node_modules in our repo or doing an npm install when checking out the code?

推荐答案

<答案并不像Alberto Zaccagni所说的那么简单。如果你开发应用程序(尤其是企业应用程序),包括git仓库中的node_modules是一个可行的选择,你选择哪一种替代方案取决于你的项目。

The answer is not as easy as Alberto Zaccagni suggests. If you develop applications (especially enterprise applications), including node_modules in your git repo is a viable choice and which alternative you choose depends on your project.

针对node_modules,我将专注于他们的论点。

Because he argued very well against node_modules I will concentrate on arguments for them.

想象一下,您刚刚完成企业应用程序,您将不得不支持它3 - 5年。你肯定不想依赖某人的npm模块,它可能明天消失,你不能再更新你的应用程序。

Imagine that you have just finished enterprise app and you will have to support it for 3-5 years. You definitely don't want to depend on someone's npm module which can tomorrow disappear and you can't update your app anymore.

或者你有你的私有模块可从互联网访问,而且无法在Internet上构建应用程序。或者你可能不想依靠npm服务上的最终构建。

Or you have your private modules which are not accessible from the internet and you can't build your app on the Internet. Or maybe you don't want to depend on your final build on npm service for some reasons.

你可以找到优点和缺点在这篇Addy Osmani文章中(尽管它是关于鲍尔的,但情况几乎相同) 。我将以Bower主页和Addy的文章引用结束:
$ b

You can find pros and cons in this Addy Osmani article (although it is about Bower, it is almost the same situation). And I will end with a quote from Bower homepage and Addy's article:


如果您未创作旨在成为被其他人占用
(例如,你正在构建一个web应用程序),你应该总是将安装的软件包
检查到源代码控制中。

"If you aren’t authoring a package that is intended to be consumed by others (e.g., you’re building a web app), you should always check installed packages into source control."

这篇关于应该“node_modules”文件夹被包含在git仓库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆