转载地址node
Bower 是 twitter 推出的一款包管理工具,基于nodejs的模块化思想,把功能分散到各个模块中,让模块和模块之间存在联系,经过 Bower 来管理模块间的这种联系。jquery
bower官网git
一旦你已经安装了上面所说的全部必要文件,键入如下命令安装Bower:github
$ npm install -g bower
这行命令是Bower的全局安装,-g 操做表示全局。express
bower install git://github.com/JSLite/JSLite.git
bower install JSLite/JSLite
bower install http://foo.com/jquery.awesome-plugin.js
bower install ./repos/jquery
$ bower install jquery --save
添加依赖并更新bower.json文件$ bower cache clean
安装失败清除缓存$ bower install storejs
安装storejs$ bower uninstall storejs
卸载storejsnpm
bower.json文件的使用可让包的安装更容易,你能够在应用程序的根目录下建立一个名为 bower.json
的文件,并定义它的依赖关系。使用bower init
命令来建立bower.json
文件:json
$ bower init ? name: store.js ? version: 1.0.1 ? description: "本地存储localstorage的封装,提供简单的AIP" ? authors: (kenny.wang <wowohoo@qq.co>) ? license: MIT ? homepage: ? set currently installed components as dependencies?: Yes ? add commonly ignored files to ignore list?: Yes ? would you like to mark this package as private which prevents it from being accidentally publis? would you like to mark this package as private which prevents it from being accidentally published to the registry?: No { name: 'store.js', main: 'store.js', version: '1.0.1', authors: [ '(kenny.wang <wowohoo@qq.co>)' ], description: '"本地存储localstorage的封装,提供简单的AIP"', moduleType: [ 'amd', 'node' ], keywords: [ 'storejs' ], license: 'MIT', ignore: [ '**/.*', 'node_modules', 'bower_components', 'test', 'tests' ] } ? Looks good?: Yes
能够注册本身的包,这样其余人也可使用了,这个操做只是在服务器上保存了一个隐射,服务器自己不托管代码。segmentfault
bower register storejs git://github.com/jaywcjlove/store.js.git
npm全称Node Package Manager,是node.js的模块依赖管理工具。使用github管理NPM包的代码,并按期提交至NPM服务器;
npm官网缓存
package.json文件的使用可让包的安装更容易,你能够在应用程序的根目录下建立一个名为 package.json
的文件,并定义它的依赖关系。使用npm init
命令来建立package.json
文件:服务器
$ npm init This utility will walk you through creating a package.json file. It only covers the most common items, and tries to guess sane defaults. See `npm help json` for definitive documentation on these fields and exactly what they do. Use `npm install <pkg> --save` afterwards to install a package and save it as a dependency in the package.json file. Press ^C at any time to quit. name: (store.js) version: (1.0.0) description: Local storage localstorage package provides a simple API entry point: (store.js) test command: store.js git repository: (https://github.com/jaywcjlove/store.js.git) keywords: store.js author: (kenny.wang <wowohoo@qq.co>) license: (ISC) MIT About to write to /Applications/XAMPP/xamppfiles/htdocs/git/github.com/myJS/store.js/package.json: { "name": "store.js", "version": "1.0.0", "description": "Local storage localstorage package provides a simple API", "main": "store.js", "scripts": { "test": "store.js" }, "repository": { "type": "git", "url": "https://github.com/jaywcjlove/store.js.git" }, "keywords": [ "store.js" ], "author": " <wowohoo@qq.co> (kenny.wang <wowohoo@qq.co>)", "license": "MIT", "bugs": { "url": "https://github.com/jaywcjlove/store.js/issues" }, "homepage": "https://github.com/jaywcjlove/store.js" } Is this ok? (yes) yes
按照提示输入用户名,密码和邮箱
npm adduser
按照提示输入用户名,密码和邮箱
npm adduser
npm publish
若是不带参数,则会在当前目录下查找package.json文件,按照该文件描述信息发布;
若是指定目录,就会在指定目录下查找package.json文件
测试是否发布成功,在官网搜索一下www.npmjs.com
注: package.json
中的name
不要又特殊字符哦
修改package.json里的版本号,从新npm publish
npm unpublish
npm install storejs
下载使用npm config set registry https://registry.npm.taobao.org
更换镜像地址npm config get registry
获取镜像地址npm dist-tag ls jslite
查看当前版本npm dedupe
尽可能压平依赖树
因为npm的源在国外,因此国内用户使用起来各类不方便。
利用kappa搭建私有NPM仓库
npm --registry https://registry.npm.taobao.org install express
npm config set registry https://registry.npm.taobao.org // 配置后可经过下面方式来验证是否成功 npm config get registry // 或 npm info express
npm install -g cnpm --registry=https://registry.npm.taobao.org // 使用 cnpm install expresstall express
听说已经不更新了,往后若是有研究再补充!