npm发布一个自己的组件包

npm发布自己的包

  1. 注册npm账号
    https://www.npmjs.com/
  2. 初始化项目
    npm init
    然后根据自己想要发的包进行填写package.json
{
  "name": "dylan-browser-info",
  "version": "1.0.0",
  "description": "Get system and browser  information",
  "private": false,
  "main": "dist/lib.umd.min.js",
  "scripts": {
    "build": "rollup -c",
    "dev": "rollup -c -w",
    "pretest": "npm run build"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/466879168/browserInfo.git"
  },
  "devDependencies": {
    "@babel/core": "^7.7.2",
    "@babel/plugin-external-helpers": "^7.2.0",
    "@babel/preset-env": "^7.7.1",
    "babel-plugin-external-helpers": "^6.22.0",
    "rollup": "^1.20.0",
    "rollup-plugin-babel": "^4.3.3",
    "rollup-plugin-commonjs": "^10.0.0",
    "rollup-plugin-node-resolve": "^5.1.0",
    "rollup-plugin-uglify": "^6.0.3"
  },
  "keywords": [
    "browser",
    "system"
  ],
  "author": "mengyang",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/466879168/browserInfo/issues"
  },
  "homepage": "https://github.com/466879168/browserInfo#readme"
}
  1. 做好之后登陆npm
    npm login
    登陆需要输入用户名、密码、邮箱
  2. 发包
    npm publish

这样一个包就发布成功了

上一篇:Rollup.js: 开源JS库的打包利器


下一篇:sqlserver grouping函数和with rollup的使用