本地开发
第一步,安装
sinopia
npm install -g sinopia
开启终端一:
第二步,启动
sinopia -l 127.0.0.1:4873
开启终端二:
cd 到某个指定仓库
mkdir unit-restful-axios(包的名称)
cd unit-restful-axios
npm init
生成package.json
PS:main 为index.js
在index.js 中复制 unit/index.js的内容
接下来 以下操作
第三步,创建新用户
npm adduser --registry http://127.0.0.1:4873
第四步,发布npm包
npm publish --registry http://127.0.0.1:4873
第五步,设置npm请求源(也可以提前设置)
npm config set registry http://127.0.0.1:4873
```js
```js
npm adduser --registry http://127.0.0.1:4873
npm publish --registry http://127.0.0.1:4873
sinopia -l 127.0.0.1:4873
npm config set registry http://127.0.0.1:4873
```js
### 线上发布
npm 官方发布
npm config set registry https://registry.npmjs.org/
npm publish
npm login
- 出现问题 callback must be a funciton received undefined local-fs.js 42行
```js
fs.unlink(tmp,function(){})
- 之后
npm adduser --registry http://127.0.0.1:4873
npm publish --registry http://127.0.0.1:4873
sinopia -l 127.0.0.1:4873
npm config set registry http://127.0.0.1:4873