我开始使用这些工具,并且仍在理解它们的元依赖性的过程中。
据我所知,Yeoman 是一个带有一些“向导”功能的 npm 客户端。它已经安装了所使用的生成器的依赖项。为什么、在哪里以及如何使用和需要 Bower?为什么 Yeoman 已经在使用 npm 时还需要另一个包系统?
我知道通常 npm 用于服务器端代码,Bower 用于客户端代码(但仍在服务器上,browserify 用于客户端)。
npm 和 Bower 都是包管理系统。正确的? 那么,为什么 Yeoman 使用两种不同的包管理系统而不是坚持使用一种呢?
<小时/>示例:我想为我的团队创建一组模板和组件,以便能够按照通用结构、样式等快速构建网站。
- 首先,我使用基本的 CSS、菜单创建一个小的空网站。我用它制作了一个 Yeoman 生成器。
- 然后我制作第二个生成器来向该网站添加一个空页面。 (我想要一个用于这种情况的生成器,以便它在菜单中创建条目,添加一些测试等)。
- 然后我想提供一些自定义组件,例如特殊表单。我通常会将其包装在 bower 包中。 但为什么不作为另一个生成器呢?
在这种情况下,发电机完全符合要求。这将是一个非常愚蠢的生成器,基本上只是将文件导入正确的文件夹中。它不会改变开发人员的流程。
最佳答案
这只是一个固执己见的决定,引用 Yeoman's :
Through our official Generators, we promote the "Yeoman workflow". This workflow is a robust and opinionated client-side stack, comprising tools and frameworks that can help developers quickly build beautiful web applications.
Bower 专为 front end components management 设计:
It offers a generic, unopinionated solution to the problem of front-end package management, while exposing the package dependency model via an API that can be consumed by a more opinionated build stack. There are no system wide dependencies, no dependencies are shared between different apps, and the dependency tree is flat.
编辑: 引用@jlafay 的评论:
...it's dependency structure remains more flat which is better suited for web pages due to a max length for url's. npm dependencies can have child dependencies and they tend to nest those child dependencies in their respective parent's directory.
关于node.js - 为什么 Yeoman 使用 Bower 而不是仅使用 npm?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24697903/