Bower和npm有什么区别? [英] What is the difference between Bower and npm?

查看:225
本文介绍了Bower和npm有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

bower npm 之间的根本区别是什么?只想要简单明了的东西。我见过我的一些同事在他们的项目中可以互换地使用 bower npm

What is the fundamental difference between bower and npm? Just want something plain and simple. I've seen some of my colleagues use bower and npm interchangeably in their projects.

推荐答案

所有包管理器都有许多缺点。你只需选择你可以使用的。

All package managers have many downsides. You just have to pick which you can live with.

npm 开始管理node.js模块(这就是默认情况下包进入 node_modules 的原因),但是当与 Browserify 或WebPack结合使用时,它也适用于前端。

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.

Bower 专为前端而设计,并在此基础上进行了优化。

Bower is created solely for the front-end and is optimized with that in mind.

npm远比bower大得多,包括通用JavaScript(如 country-data 用于国家/地区信息或排序用于排序可在前端或后端使用的功能。)

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).

Bower的包裹数量要少得多。

Bower has a much smaller amount of packages.

Bower包括样式等。

Bower includes styles etc.

npm专注于JavaScript。样式要么单独下载,要么需要 npm-sass sass-npm

npm is focused on JavaScript. Styles are either downloaded seperately or required by something like npm-sass or sass-npm.

最大的区别是npm执行嵌套依赖项(但默认情况下是平的),而Bower需要一个平面依赖树(将依赖项解析的负担放在用户身上)

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 v3开始,依赖关系树将默认为flat(节省空间),并且只在需要的地方嵌套,例如,如果两个依赖关系需要他们自己的Underscore版本。

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 depndency 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.

有些项目同时使用Bower作为前端软件包,npm用于开发人员工具,如Yeoman,Grunt,Gulp,JSHint,CoffeeScript等。

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.

  • Nested Dependencies - Insight into why node_modules works the way it does

这篇关于Bower和npm有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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