npm全稱Node Package Manager,是node.js的模塊依賴管理工具。使用github管理NPM包的代碼,並按期提交至NPM服務器;
npm官網node
package.json文件的使用能夠讓包的安裝更容易,你能夠在應用程序的根目錄下建立一個名爲 package.json
的文件,並定義它的依賴關係。使用npm init
命令來建立package.json
文件:git
$ 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 |
按照提示輸入用戶名,密碼和郵箱github
npm adduser |
按照提示輸入用戶名,密碼和郵箱npm
npm login |
npm publish |
若是不帶參數,則會在當前目錄下查找package.json文件,按照該文件描述信息發佈;
若是指定目錄,就會在指定目錄下查找package.json文件
測試是否發佈成功,在官網搜索一下www.npmjs.comjson
注: package.json
中的name
不要又特殊字符哦服務器
修改package.json裏的版本號,從新npm publishide
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
儘可能壓平依賴樹工具