轉載地址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
聽說已經不更新了,往後若是有研究再補充!