搭建私有NPM平台(搭建=>使用 简化版)

108 阅读1分钟

第一步

mkdir private-npm
cd private-npm
npm install verdaccio
npm install pm2

设置启动命令

image.png

npm run start // 启动

image.png 图中的包是后续上传上去的,能打开网页就行。http://localhost:4873/

第二步

新建npm包,准备发布至私有npm平台

cd ..
mkdir package
cd package
npm init // 一路回车下去也行 或者填写一些信息
npm set registry http://localhost:4873
npm adduser --registry http://localhost:4873 // 注册你的用户名和信息
npm publish --registry http://localhost:4873 // 发布至你的平台

npm init 配置如下 image.png

package/index.js

image.png

使用

image.png