Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
372 views
in Technique[技术] by (71.8m points)

javascript - Bower和npm有什么区别?(What is the difference between Bower and npm?)

What is the fundamental difference between bower and npm ?

(bowernpm之间的根本区别是什么?)

Just want something plain and simple.

(只需要简单明了的东西。)

I've seen some of my colleagues use bower and npm interchangeably in their projects.

(我已经看到一些同事在他们的项目中交替使用bowernpm 。)

  ask by Games Brainiac translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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的原因),但是当与Browserifywebpack结合使用时,它也适用于前端。)

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-sasssass-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(资源资源)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...