如何下载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: bower version

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

  • Webpack: https://webpack.github.io/docs/installation.html

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

 

转载于:https://www.cnblogs.com/chucklu/p/11081138.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/248656.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

PHP从零开始--字段修饰符数据操作SQL语言

文章目录一、 字段修饰符1.1主键1.2自动增长1.3非空1.4默认值1.5外键二、 对数据的操作2.1增加数据2.2删除数据2.3更新数据2.4查询数据2.4.1查询所有的数据2.4.2查询指定字段2.4.3去除重复字段2.4.4where表达式详解2.4.5分组查询2.4.6排序三、 SQL语言3.1DML3.2DDL3.3DCL一、 字…

scrapy爬虫框架windows下的安装问题

windows操作系统python版本是3.6.0通过Anaconda命令conda install scrapy安装scrapy,安装过程中没有问题。然后在命令行输入命令准备新建项目时&#xff0c;输入 scrapy startproject firstscrapy时出现了from cryptography.hazmat.bindings._openssl import ffi, libImportErr…

charles使用说明(基于mac)

1. Charles简介 1.1 Charles 需要java的运行环境支持&#xff0c;支持Windows、Mac&#xff1b;Fiddler不支持Mac。故Charles是在Mac下常用的网络封包截取工具。 1.2 Charles原理&#xff1a;通过将自己设置成系统的网络访问代理服务器&#xff0c;使得所有的网络访问请求都通过…

看完就懂的连表查询

文章目录一、表与表之间的关系1.1一对一1.2一对多1.3多对多二、 连表查询2.1概念2.2笛卡尔积2.3内连接2.4外连接2.4.1左外连接2.4.2右外连接2.4.3全连接2.4.4navicat导入导成sql语句2.4.5练习三、 子查询3.1概念3.2练习3.2.1查询工资最高的员工所有信息3.2.2查询工资比7654工资…

三分钟掌握PHP操作数据库

这里写自定义目录标题一、 操作数据库&#xff08;mysql&#xff09;的工具1.1命令行工具1.2navicat界面化工具1.3phpAdmin界面化工具二、 表单传值2.1文本框和文本域传值2.2单选框传值2.4下拉菜单传值三、 php连接数据库3.1连接方式介绍3.2mysqli基础步骤3.2.1创建连接3.2.2选…

看完就会的文件编程

文章目录文件编程1.1文件操作函数1.1.1file()函数1.1.2fopen fgets fclose1.2.1读取模式1.2.2写入内容&#xff08;开头&#xff09;1.2.3写入内容&#xff08;追加&#xff09;1.1.3file_get_contents1.1.4文件路径相关函数1.1.5file_exists1.1.6feof1.1.7copy()1.1.8set_incl…

一文吃透PHP和HTML的嵌套写法

1.1全部php生成结构 1.2html中嵌套php 总结如下&#xff1a; html和php混写规则&#xff1a; php代码必须包在<?php ?>html中写php也是同理&#xff0c;但是有值输出必须加上echo 1.3博客项目 1.3.1前后台 前台主要是做数据展示的&#xff0c;所有的用户通过访问域…

一文看懂 GD2库

文章目录一、 GD2简介1、 验证码&#xff08;实际上是一个img&#xff09;二、 GD2库使用步骤2.1添加扩展2.2修改php配置文件2.3重启服务三、 GD2里面的常用方法3.1 imagecreate3.2 imagecolorallocate3.3 imagefill3.4 输出图像资源3.5创建真彩画布3.6在图像中写文字3.6.1imag…

算法实践--最小生成树(Kruskal算法)

什么是最小生成树(Minimum Spanning Tree) 每两个端点之间的边都有一个权重值&#xff0c;最小生成树是这些边的一个子集。这些边可以将所有端点连到一起&#xff0c;且总的权重最小 下图所示的例子&#xff0c;最小生成树是{cf, fa, ab} 3条边 Kruskal算法 用到上一篇中介绍的…

洽谈 “会话技术” 纯干货赶紧收藏吧

文章目录一、 HTTP协议二、 会话三、 cookie3.1概念和设置cookie3.2读取cookie3.3设置cookie有效期3.4cookie是跨页面的3.5删除cookie3.6登录案例3.7cookie特点四、 session4.1概念4.2设置session4.3获取session4.4清除session4.5模拟购物车案例一、 HTTP协议 HTTP协议是Hyper…

[bzoj2729][HNOI2012]排队 题解 (排列组合 高精)

Description 某中学有 n 名男同学&#xff0c;m 名女同学和两名老师要排队参加体检。他们排成一条直线&#xff0c;并且任意两名女同学不能相邻&#xff0c;两名老师也不能相邻&#xff0c;那么一共有多少种排法呢&#xff1f;&#xff08;注意&#xff1a;任意两个人都是不同的…

详解 正则表达式

文章目录一、概念二、作用三、语法规则3.1定义规则3.2符号简介3.3preg_match用法详解3.4详解元字符3.4.1 \d和[0-9]3.4.2 \D和[^0-9]3.4.3^和$3.4.4*代表出现0次或者多次3.4.5代表出现1次或者多次3.4.5&#xff1f;代表出现0次或者1次3.4.6{n}3.4.7{n,}3.4.8{n,m}3.4.9点号&…

Java:控制台输入车辆信息,将信息保存至数据库中

程序功能&#xff1a;控制台输入车辆信息&#xff0c;将信息保存至数据库中 程序代码如下&#xff1a; BaseDao.java package DAO_dome.kehozuoye; import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.ResultSet;i…

echars 3D地图为区域自定义颜色

echars 3D地图为区域自定义颜色问题延伸解决问题问题 根据项目需求&#xff0c;我们要将下面省级地图中的个别市进行高亮&#xff08;不同颜色&#xff09;展示 延伸 首先跟大家介绍这个地图的展示方式&#xff1a; 采用的是Vue框架中运用echarts地图采用的是geo3D和scatt…

基于Python语言使用RabbitMQ消息队列(一)

介绍 RabbitMQ 是一个消息中间人&#xff08;broker&#xff09;: 它接收并且发送消息. 你可以把它想象成一个邮局: 当你把想要寄出的信放到邮筒里时, 你可以确定邮递员会把信件送到收信人那里. 在这个比喻中, RabbitMQ 就是一个邮筒, 同时也是邮局和邮递员 . 和邮局的主要不同…

爆赞程序猿开发软件

VSCode 使用 IntelliSense 超越语法突出显示和自动完成&#xff0c;它提供基于变量类型、函数定义和导入模块的智能完成 直接从编辑器调试代码。启动或附加到您正在运行的应用程序并使用断点、调用堆栈和交互式控制台进行调试 与 Git 和其他 SCM 提供商合作从未如此简单。查…

如果你在北京失业了,别怕,记得去领这笔钱!最少2034元/月!

人在江湖飘&#xff0c;哪能不挨刀 公司倒闭&#xff0c;老板走人&#xff0c;公司裁人 …… 就要被迫失业了 别怕! 如果你在北京失业了 记得去领这笔钱——失业保险金 每月最多有2143元 虽然钱不多&#xff0c;但能解燃眉之急 帮助你度过困难日子 重点全程网上就能…

真实诠释程序员日常的二十四张图【你中了几个】

当你打开遗留代码时 扒下来项目后改了一行代码…… 程序员调试css样式的时候 当你的try catch 不起作用 产品经理对你说要兼容IE 没有ui给你提供大小设计的结果 没吃透需求直接开发的你 程序员修复bug的真实处境 当你开始使用库&#xff0c;但忘记阅读文档 产品经理告诉你这只是…

Git学习原版手稿

手稿诞生记 Git学习的时候难免会有遗忘然后往复学习查看的过程&#xff0c;所以就形成了这个学习的手稿&#xff0c;记录了Git使用过程中的大部分命令&#xff0c;今天在清理的时候偶然看到了这些记录&#xff0c;而且最近也在写Git的使用教程&#xff0c;大致的学习线路也是按…

程序员首选编程电脑【火爆来袭】

作为一名程序员肯定会常用到一些编程软件&#xff0c;所以需要设备的配置参数上不能太差&#xff0c;不仅是要以稳定强大输出为基本&#xff0c;内存、音响、续航等方面也不可或缺。 直奔主题 如果你手里资金到位&#xff0c;那必须整一步到位——MacBook 对于这款大佬型笔记本…