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

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

问题描述

bowernpm 的根本区别是什么?只想要简单明了的东西.我看到我的一些同事在他们的项目中交替使用 bowernpm.

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 的原因)默认情况下),但当与 Browserifywebpack.

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 或用于前端可用的排序功能的 sorts或后端).

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-sasssass-npm 之类的东西要求.

npm is focused on JavaScript. Styles are either downloaded separately 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 开始,依赖树默认是扁平的(节省空间)并且只在需要的地方嵌套,例如,如果两个依赖项需要它们自己的 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 dependency and still work. Note since npm v3, the dependency tree will be flat by default (saving space) and only nest where needed, e.g., if two dependencies need their own version of Underscore.

有些项目同时使用两者:他们将 Bower 用于前端包,将 npm 用于 Yeoman、Grunt、Gulp、JSHint、CoffeeScript 等开发人员工具.

Some projects use both: 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天全站免登陆