npm发布包
1.注册一个账号https://www.npmjs.com,填写邮箱,每次登录都会发送一个一次性密码到你的邮箱;
2.在本地编写模块, npm init 填写相关信息
3.新建index.js文件,编写模块代码
exports.sayHello = function () { return "HELLO WORLD"; }
4.终端中登录npm,命令 npm adduser ,不登录发布会报如下错误:
5.上传包: npm publish . ,包名不可以和现有的npm仓库重名,否则报如下错误,上传成功后就可以在npm上搜索到自己的包文件
6.安装包:npm install 包名