从0到1发布一个npm包的步骤
1.注册一个npm账号
2.注册账号后验证自己的邮箱,这个在发布包事会提示警告
3 本地代码开发
1.npm init 后会生成一个package.json文件
{
"name": "drag_xie",
"version": "1.0.5",
"description": "发布的第一个npm包",
"main": "lib/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "golury",
"license": "ISC"
}
2.项目目录
3.index.js 文件内容
var xietest = function xietest() {
console.log('hello');
console.log('************第一个npm包**********');
}
module.exports = xietest;
4.npm发布
1.npm login 输入npm注册的用户名,密码,邮箱
注意:Logged in as xxx on http://registry.npmjs.org/. 这里有上传路径,上传npm之前设置
npm config set registry=http://registry.npmjs.org