作为前端程程序员,npm包管理是需要经常使用的,封装自己的组件包,方便使用是有必要的,文章介绍发布npm组件包的全过程,以备不时之需。
本文介绍如何上传自己的NPM组件包到NPM库中,当你写好自己的NMP组件或者根据需求修改某个组件后想共享给别人或者公司同事使用的时候,你可以使用NPM publish 命令提交上去,要经过审核。但你可以上传到自己的公司的服务器库 如何搭建NPM私人服务器 参考 链接
初始化Package.json
npm init
验证npm账号
npm adduser
发布
npm publish
package.json 实例
{
"name": "RNSVG",
"version": "0.1.0",
"description": "An easy mongodb client for node.js based on native mongodb driver.",
"main": "./index.js",
"directories": {
"example": "examples"
},
"scripts": {
"test": "make test"
},
"repository": {
"type": "git",
"url": "https://github.com/YuXueBJ/react-native-xsy-svg.git"
},
"keywords": [
"react-component",
"react-native",
"ios",
"android",
"SVG",
"ART",
"VML"
],
"author": "zhwios",
"license": "MIT",
"bugs": {
"url": "https://github.com/YuXueBJ/react-native-xsy-svg"
}
}