https://bower.io/  这个已经淘汰

https://learn.jquery.com/jquery-ui/environments/bower/

Web sites are made of lots of things — frameworks, libraries, assets, and utilities. Bower manages all these things for you.

Keeping track of all these packages and making sure they are up to date (or set to the specific versions you need) is tricky. Bower to the rescue!

Bower can manage components that contain HTML, CSS, JavaScript, fonts or even image files. Bower doesn’t concatenate or minify code or do anything else - it just installs the right versions of the packages you need and their dependencies.

To get started, Bower works by fetching and installing packages from all over, taking care of hunting, finding, downloading, and saving the stuff you’re looking for. Bower keeps track of these packages in a manifest file, bower.json. How you use packages is up to you. Bower provides hooks to facilitate using packages in your tools and workflows.

Bower is optimized for the front-end. If multiple packages depend on a package - jQuery for example - Bower will download jQuery just once. This is known as a flat dependency graph and it helps reduce page load.

Install Bower

Bower is a command line utility. Install it with npm.

npm install -g bower

Bower requires node, npm and git.

Latest release:

For troubleshooting installation on different platforms, read the troubleshooting wiki page.

Getting started

Install packages

Install packages with bower install. Bower installs packages to bower_components/.

bower install <package>

A package can be a GitHub shorthand, a Git endpoint, a URL, and more. Read more about bower install.

# installs the project dependencies listed in bower.json
bower install
# registered package
bower install jquery
# GitHub shorthand
bower install desandro/masonry
# Git endpoint
bower install git://github.com/user/package.git
# URL
bower install http://example.com/script.js

Search packages

Search Bower packages and find the registered package names for your favorite projects.

Save packages

Create a bower.json file for your package with bower init.

Then save new dependencies to your bower.json with bower install PACKAGE --save

Use packages

How you use packages is up to you. We recommend you use Bower together with Grunt, RequireJS, Yeoman, and lots of other tools or build your own workflow with the API. You can also use the installed packages directly, like this, in the case of jquery:

<script src="bower_components/jquery/dist/jquery.min.js"></script>

实例

https://libraries.io/bower/blueimp-file-upload

bower install blueimp-file-upload       

安装完成后可以查看版本

https://stedolan.github.io/jq/

https://shapeshed.com/jq-json/#how-to-find-a-key-and-value

https://github.com/stedolan/jq/wiki/Installation#windows-with-choco

cat bower_components/blueimp-file-upload/.bower.json | ./jq-win64.exe '.version'
"9.32.0"

npm

https://www.npmjs.com/package/blueimp-file-upload

npm i blueimp-file-upload

Bye, bye, Bower! Or how to migrate from Bower to npm and Webpack

Bower is going away. Even the bower team is recommending developers to move over to npm (or Yarn which I personally prefer) and Webpack. As one can see from the screenshot, we get the following warning when running npm i bower from cli.

Difference between Grunt, NPM and Bower ( package.json vs bower.json )

 

Update for mid 2016:

The things are changing so fast that if it's late 2017 this answer might not be up to date anymore!

Beginners can quickly get lost in choice of build tools and workflows, but what's most up to date in 2016 is not using Bower, Grunt or Gulp at all! With help of Webpack you can do everything directly in NPM!

Don't get me wrong people use other workflows and I still use GULP in my legacy project(but slowly moving out of it), but this is how it's done in the best companies and developers working in this workflow make a LOT of money!

Look at this template it's a very up-to-date setup consisting of a mixture of the best and the latest technologies: https://github.com/coryhouse/react-slingshot

  • Webpack
  • NPM as a build tool (no Gulp, Grunt or Bower)
  • React with Redux
  • ESLint
  • the list is long. Go and explore!

Your questions:

When I want to add a package (and check in the dependency into git), where does it belong - into package.json or into bower.json

  • Everything belongs in package.json now

  • Dependencies required for build are in "devDependencies" i.e. npm install require-dir --save-dev (--save-dev updates your package.json by adding an entry to devDependencies)

  • Dependencies required for your application during runtime are in "dependencies" i.e. npm install lodash --save (--save updates your package.json by adding an entry to dependencies)

If that is the case, when should I ever install packages explicitly like that without adding them to the file that manages dependencies (apart from installing command line tools globally)?

Always. Just because of comfort. When you add a flag (--save-dev or --save) the file that manages deps (package.json) gets updated automatically. Don't waste time by editing dependencies in it manually. Shortcut for npm install --save-dev package-name is npm i -D package-name and shortcut for npm install --save package-name is npm i -S package-name

最新文章

  1. css三级菜单效果
  2. oracle数据库导入、导出
  3. 信鸽推送(XGPush)
  4. 使用 CSS3 打造一组质感细腻丝滑的按钮
  5. 面向对象的JavaScript(一)命名空间
  6. Sharepoint学习笔记—习题系列--70-573习题解析 -(Q81-Q84)
  7. POJ 1201 Intervals
  8. Linux按照CPU、内存、磁盘IO、网络性能监测
  9. java 集合(Map)
  10. JS范围
  11. Objective-C ,ios,iphone开发基础:使用第三方库FMDB连接sqlite3 数据库,实现简单的登录
  12. 打造自己博客(wordpress)的wap手机版本
  13. HDU 3903 Trigonometric Function
  14. SAP中常用SM系列事务代码总结
  15. maven pom 引入本地jar包
  16. eclipse 中git无法https下载提交代码
  17. 2018.7.3 lnmp一键安装包无人值守版本 php7.2 + nginx1.14.0 + mariadb5.5 + centos7.1(1503) 环境搭建 + Thinkphp5.1.7 配置
  18. 使用IntelliJ IDEA新建Java Web后端resfulAPI模板
  19. 阿里云 持续集成环境自动部署cordova项目热更新脚本
  20. java web实践

热门文章

  1. ue4 3dui材质参数修改
  2. IT兄弟连 JavaWeb教程 过滤器2
  3. IT兄弟连 JavaWeb教程 过滤器1
  4. appium自动化测试框架——在python脚本中执行dos命令
  5. LCS最大公共子序列【转载】
  6. 使用JS判断客户端、浏览器、操作系统类型
  7. [题解](组合数学/gcd)luogu_P3166数三角形
  8. struts2.5+框架使用通配符与动态方法
  9. php:获取一个表不含text类型的全部字段
  10. eclipse查看jar包源文件