一、启动nexus
进入解压包所在位置 nexus-3.29.1-01,下bin目录,打开cmd窗口,输入
.nexus/start
二、先build,再去发布
在项目中 npm i (注意镜像地址 npm 或者taobao )
获取镜像地址
npm config get registry
设置镜像地址
npm config set registry https://registry.npm.taobao.org
在项目中
npm build
进入生成的插件目录 这个名字是在package.json里面配置的smallbutton
cd smallbutton
npm publish
注意:没有登录的,先 切换镜像,再发布
npm config set registry=http://服务器地址:8081/repository/npm-internal/
npm login -registry=http://服务器地址:8081/repository/npm-internal/
输入用户名、密码、邮箱
发布成功!
进入到需要用到插件的项目,package.json 里面加入
"smalllbutton":'^1.0.1'
npm i smallbutton
注意插件文件名不可以有大写,插件名字必须为小写,function 组件得函数名可以为大写
import {SmallButton} from 'smallbutton'
<SmallButton/>