All package managers have many downsides.
(所有程序包管理器都有很多缺点。)
You just have to pick which you can live with.(您只需要选择可以忍受的内容即可。)
History(历史)
npm started out managing node.js modules (that's why packages go into node_modules
by default), but it works for the front-end too when combined with Browserify or webpack .
(npm开始管理node.js模块(这就是为什么软件包默认进入node_modules
的原因),但是当与Browserify或webpack结合使用时,它也适用于前端。)
Bower is created solely for the front-end and is optimized with that in mind.
(Bower是专门为前端创建的,并且考虑到这一点已进行了优化。)
Size of repo(回购规模)
npm is much, much larger than bower, including general purpose JavaScript (like country-data
for country information or sorts
for sorting functions that is usable on the front end or the back end).
(NPM是多少,比亭子,包括通用的JavaScript大得多(如country-data
为国家信息或sorts
用于分拣功能是在前端或后端可用)。)
Bower has a much smaller amount of packages.
(Bower的包装数量要少得多。)
Handling of styles etc(样式等的处理)
Bower includes styles etc.
(凉亭包括样式等。)
npm is focused on JavaScript.
(npm专注于JavaScript。)
Styles are either downloaded separately or required by something like npm-sass
or sass-npm
.(样式要么单独下载,要么需要npm-sass
或sass-npm
类的样式。)
Dependency handling(依赖处理)
The biggest difference is that npm does nested dependencies (but is flat by default) while Bower requires a flat dependency tree (puts the burden of dependency resolution on the user) .
(最大的区别是npm确实嵌套了依赖项(但默认情况下是平坦的),而Bower需要平坦的依赖项树(这给用户带来了依赖项解决的负担) 。)
A nested dependency tree means that your dependencies can have their own dependencies which can have their own, and so on.
(嵌套的依赖关系树意味着您的依赖关系可以具有自己的依赖关系,也可以具有自己的依此类推。)
This allows for two modules to require different versions of the same dependency and still work.(这允许两个模块要求具有相同依赖项的不同版本,并且仍然可以工作。)
Note since npm v3, the dependency tree will by flat by default (saving space) and only nest where needed, eg, if two dependencies need their own version of Underscore.(请注意,从npm v3开始,依赖项树默认情况下将是扁平的(节省空间),并且仅在需要的地方嵌套,例如,如果两个依赖项需要它们自己的Underscore版本。)
Some projects use both is that they use Bower for front-end packages and npm for developer tools like Yeoman, Grunt, Gulp, JSHint, CoffeeScript, etc.
(一些项目同时使用这两种方法,即它们将Bower用于前端软件包,将npm用于开发人员工具,例如Yeoman,Grunt,Gulp,JSHint,CoffeeScript等。)
Resources(资源资源)