如何下载js类库
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!
Google "npm as build tool" result: https://medium.com/@dabit3/introduction-to-using-npm-as-a-build-tool-b41076f488b0#.c33e74tsa
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
如何下载js类库的更多相关文章
- 基于js-spark-md5前端js类库,快速获取文件Md5值
js-spark-md5是歪果仁开发的东西,有点多,但是我们只要一个js文件即可,具体类包我存在自己的oschina上,下载地址:https://git.oschina.net/jianqingwan ...
- php大力力 [029节] 做PHP项目如何下载js文件:使用腾讯浏览器把网上案例页面存储到本地
php大力力 [029节] 做PHP项目如何下载js文件:使用腾讯浏览器把网上案例页面存储到本地 yeah,搞定啦 php大力力 [029节] 做PHP项目如何下载js文件:使用腾讯浏览器把网上案例页 ...
- php大力力 [028节] 如何下载js文件,网上一个*.js无法下载啊??????
php大力力 [028节] 如何下载js文件,网上一个*.js无法下载啊?????? safari也无法下载 迅雷也无法下载 是不是对方网站服务器的不让下载那个js目录的文件??? 只能调用js函数啊 ...
- 简单轻量级的一套JS 类库(RapidDevelopmentFramework.JS)
1.最近好久没有更新自己的博客了,一直在考虑自己应该写一些什么.4.2日从苏州回到南京的路上感觉自己的内心些崩溃和失落,我就不多说了? 猛然之间我认为自己需要找一下内心的平衡.决定开发属于自己一套快速 ...
- 封装的一套简单轻量级JS 类库(RapidDevelopmentFramework.JS)
1.最近好久没有更新自己的博客了,一直在考虑自己应该写一些什么.4.2日从苏州回到南京的路上感觉自己的内心些崩溃和失落,我就不多说了? 猛然之间我认为自己需要找一下内心的平衡.决定开发属于自己一套快速 ...
- 【js类库AngularJs】学习angularJs的指令(包括常见表单验证,隐藏等功能)
[js类库AngularJs]学习angularJs的指令(包括常见表单验证,隐藏等功能) AngularJS诞生于2009年,由Misko Hevery 等人创建,后为Google所收购.是一款优秀 ...
- 【js类库AngularJs】解决angular+springmvc的post提交问题
[js类库AngularJs]解决angular+springmvc的post提交问题 AngularJS诞生于2009年,由Misko Hevery 等人创建,后为Google所收购.是一款优秀的前 ...
- 如何在TypeScript中使用JS类库
使用流程 1.首先要清除类库是什么类型,不同的类库有不同的使用方式 2.寻找声明文件 JS类库一般有三类:全局类库.模块类库.UMD库.例如,jQuery是一种UMD库,既可以通过全局方式来引用,也可 ...
- 前端UI框架和JS类库
一.前端框架库: 1.Zepto.js 地址:http://www.css88.com/doc/zeptojs/ 描述:Zepto是一个轻量级的针对现代高级浏览器的JavaScript库, 它与jqu ...
随机推荐
- html解决的兼容问题
手机版不缩放 <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum ...
- keycode和which
firefox 中不支持keyCode ie9-- 不支持which firefox:上下左右键会触发kepress. chrome: 上下左右键不会触发kepress. oprea:上下左右键不会触 ...
- UE4]不使用角色蓝图、动画蓝图、状态机,用“24K纯C++”实现动画播放
http://aigo.iteye.com/blog/2283454 原文作者:@玄冬Wong 不好意思,我稍稍标题党了,目前还不清楚如何用C++代码来实现BlendSpace和Montage的逻辑, ...
- js函数-构成
前言 函数是一种封装,在任何语言中都是一个核心概念.在js中,函数是做为对象的子类型存在的.可以拥有自己的属性和方法,可以做为值进行传递,这两个特性让js拥有使用函数式编程的能力. 函数的声明 字面量 ...
- mac系统之前做过Windows8系统,可能移除时没有通过boot camp助理移除,所以想要再安装windows系统时,点击boot camp助理的继续,弹出启动磁盘不能被分区或恢复单分区。
因为把bootcamp分区抹掉,卸载,装载,点减号,合并成单分区,一直是操作失败.为了通过boot camp安装上Windows系统,索性重新安装mac ox系统,重新分区.重新开机,按住comman ...
- Jmeter 的 vars 和 props 用法
meter 的 JSR223 控件是 代替 BeanShell 的新一代脚本控件,支持多种脚本语言,尤其是其中的 Groovy,更是重点推荐使用的脚本语言,本文研究其中的 vars 和 props 两 ...
- safari不支持new Date函数
最近在做移动Web的时候,在PC上用Chrome调试都成功了,但是在iPhone上真机一测就出现了奇怪的问题.经过一系列调试发现是日期相关的地方出现了问题.起初怀疑是生产环境的问题,但用Mac版的sa ...
- CodeForces - 287B-Pipeline(二分)
Vova, the Ultimate Thule new shaman, wants to build a pipeline. As there are exactly n houses in Ult ...
- hdu2510-符号三角形(dfs+打表)
n只有24 可以写个暴力搜索,然后打表,不然这个很难通过剪枝直接优化到1s以内. #include<bits/stdc++.h> #define inf 0x3f3f3f3f ; usin ...
- Uva1377
/* 在n个刻度和他们的差里挑不超过7个刻度,0是固定的,最大的刻度肯定是最大值,然后剩下的dfs挑. */ #include<bits/stdc++.h> #define inf 0x3 ...