I started a project without using bower (initially). I'm using AngularJS, Browserify, Gulp, Node.js, etc. and did not install any other front-end dependencies yet. Now that I want to make use of Bootstrap and FontAwesome, I was going to install and use Bower. However, since AngularJS can be installed with both bower and npm...
我开始一个项目时没有使用bower(最初)。我用的是AngularJS, Browserify, Gulp, Node。还没有安装任何其他前端依赖项。现在我想利用Bootstrap和FontAwesome,我打算安装和使用Bower。但是,由于AngularJS可以同时安装bower和npm…
Which is the better use case for installing AngularJS (Bower or NPM)? Why would one prevail over the other? Does it just come down to personal preference?
安装AngularJS (Bower或NPM)的更好用例是什么?为什么一个会战胜另一个?这仅仅取决于个人喜好吗?
2 个解决方案
#1
3
It sounds like you already have your environment for this project setup to utilize npm, I'd not let a few more dependencies cause you to have to question that setup. Especially things like Bootstrap & Font Awesome that can be embedded into your index.html via the CDN links.
听起来您已经有了这个项目设置的环境来利用npm,我不会让更多的依赖关系导致您不得不质疑这个设置。特别是像Bootstrap和Font Awesome这样的东西可以嵌入到你的索引中。html通过CDN链接。
Typically questions like these don't yield the expected answer. There is no right answer across the board. This is akin to asking:
通常这样的问题不会产生预期的答案。所有人都没有正确的答案。这类似于问:
"Hey guys, which do you prefer: A claw hammer or a ball-peen hammer? I have this thing I am building."
“嘿,伙计们,你们更喜欢哪一个:羊角锤还是球头锤?”我有一件我正在建造的东西。”
There are only right answers within the context of your current setup, which you've already chosen by starting it with gulp & browserify.
在当前设置的上下文中,只有正确的答案,您已经从gulp & browserify开始选择了它。
But to play along...
但一起玩……
Bower is good if you like:
如果你喜欢,凉亭是好的。
- asynchronous (albeit, somewhat more exposed) dependencies
- 异步依赖项(尽管有些暴露)
- less learning curve/setup, more "get it done"
- 更少的学习曲线/设置,更多的“完成”
- not having a bazillion options
- 没有太多的选择
- enjoy the AMD dependency model
define(['dep'], function (dep) {return function () {};});
- 享受AMD依赖模型定义(['dep'],函数(dep) {return function () {};});
npm is good if you like:
如果你喜欢,npm是好的:
- compiling your coffeescript/typescript/ into heftier javascript files (I haven't done this with Bower so I don't know if it offers some of the transpiling options, I assume it does)
- 将您的coffecript /typescript/编译到heftier javascript文件中(我还没有用Bower做过这个,所以我不知道它是否提供了一些转换选项,我想它提供了)
- want to leverage node's existing extensive library of packages (via browserify/webpack)
- 想要利用node现有的大量包库(通过browserify/webpack)
- want more customization over how you build your app
- 想要更多关于如何构建应用程序的定制
- enjoy the Common JS dependency model
module.exports = ...
- 享受常见的JS依赖模型模块。出口=…
I'm sure others can comment on the pros/cons of each.
我相信其他人可以评论各自的优缺点。
#2
0
The main difference is how they handle dependencies (nested for npm2 vs flat for bower)
主要的区别是它们如何处理依赖关系(嵌套在npm2 vs . bower平台上)
It depends on your project, but in general I find it more "visible" if you start putting several versions of the same js library because dependencies... but the price is that you might end up banging your head a fair bit to find how to keep everyone happy with the same version.
这取决于您的项目,但一般来说,如果您开始放置相同的js库的多个版本,我发现它更“可见”,因为依赖项……但代价是,你可能最终会撞到自己的头,以找到如何让每个人都满意的相同版本。
As kelvin and helpermethod pointed out, npm3 does flatten the dependencies. At the end of the day, it's a matter of preferences, take whatever you prefer living with, both work ok
正如kelvin和helpermethod所指出的,npm3确实降低了依赖性。在一天结束的时候,这是一个偏好的问题,选择你喜欢的生活方式,两者都可以
#1
3
It sounds like you already have your environment for this project setup to utilize npm, I'd not let a few more dependencies cause you to have to question that setup. Especially things like Bootstrap & Font Awesome that can be embedded into your index.html via the CDN links.
听起来您已经有了这个项目设置的环境来利用npm,我不会让更多的依赖关系导致您不得不质疑这个设置。特别是像Bootstrap和Font Awesome这样的东西可以嵌入到你的索引中。html通过CDN链接。
Typically questions like these don't yield the expected answer. There is no right answer across the board. This is akin to asking:
通常这样的问题不会产生预期的答案。所有人都没有正确的答案。这类似于问:
"Hey guys, which do you prefer: A claw hammer or a ball-peen hammer? I have this thing I am building."
“嘿,伙计们,你们更喜欢哪一个:羊角锤还是球头锤?”我有一件我正在建造的东西。”
There are only right answers within the context of your current setup, which you've already chosen by starting it with gulp & browserify.
在当前设置的上下文中,只有正确的答案,您已经从gulp & browserify开始选择了它。
But to play along...
但一起玩……
Bower is good if you like:
如果你喜欢,凉亭是好的。
- asynchronous (albeit, somewhat more exposed) dependencies
- 异步依赖项(尽管有些暴露)
- less learning curve/setup, more "get it done"
- 更少的学习曲线/设置,更多的“完成”
- not having a bazillion options
- 没有太多的选择
- enjoy the AMD dependency model
define(['dep'], function (dep) {return function () {};});
- 享受AMD依赖模型定义(['dep'],函数(dep) {return function () {};});
npm is good if you like:
如果你喜欢,npm是好的:
- compiling your coffeescript/typescript/ into heftier javascript files (I haven't done this with Bower so I don't know if it offers some of the transpiling options, I assume it does)
- 将您的coffecript /typescript/编译到heftier javascript文件中(我还没有用Bower做过这个,所以我不知道它是否提供了一些转换选项,我想它提供了)
- want to leverage node's existing extensive library of packages (via browserify/webpack)
- 想要利用node现有的大量包库(通过browserify/webpack)
- want more customization over how you build your app
- 想要更多关于如何构建应用程序的定制
- enjoy the Common JS dependency model
module.exports = ...
- 享受常见的JS依赖模型模块。出口=…
I'm sure others can comment on the pros/cons of each.
我相信其他人可以评论各自的优缺点。
#2
0
The main difference is how they handle dependencies (nested for npm2 vs flat for bower)
主要的区别是它们如何处理依赖关系(嵌套在npm2 vs . bower平台上)
It depends on your project, but in general I find it more "visible" if you start putting several versions of the same js library because dependencies... but the price is that you might end up banging your head a fair bit to find how to keep everyone happy with the same version.
这取决于您的项目,但一般来说,如果您开始放置相同的js库的多个版本,我发现它更“可见”,因为依赖项……但代价是,你可能最终会撞到自己的头,以找到如何让每个人都满意的相同版本。
As kelvin and helpermethod pointed out, npm3 does flatten the dependencies. At the end of the day, it's a matter of preferences, take whatever you prefer living with, both work ok
正如kelvin和helpermethod所指出的,npm3确实降低了依赖性。在一天结束的时候,这是一个偏好的问题,选择你喜欢的生活方式,两者都可以