安装
npm install --location=global verdaccio@next
启动
npx verdaccio
配置文件位置
# 位置
~/.config/verdaccio/config.yaml
#主要修改以下内容
#包存储位置
storage: /abc/verdaccio/storage
#代理远程仓库地址
uplinks:
npmjs:
url: https://registry.npmmirror.com/
#修改上传包最大限制
max_body_size: 100mb
添加用户
npm adduser --registry http://localhost:4873/
发布
- 打包
vue-cli-service build --target lib --name my --dest my ./src/package/index.js
//index.js
import SeanElTable from './sean/SeanElTable.vue'
import { version } from '../../package.json'
const components = [SeanElTable]; // 将来如果有其它组件,都可以写到这个数组里
// 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
const install = function (Vue) {
// 判断是否安装
if (install.installed) return
install.installed = true
// 遍历注册全局组件
components.map(component => Vue.component(component.name, component))
}
if (typeof window !== 'undefined' && window.Vue) {
install(window.Vue)
}
// 按需引入
export {
CkEditor,
CkViewer,
SeanElTable,
MdEditor,
MdViewer
}
export default {
version,
install
}
- 发布
#bin/bash
cp README.md my/
cp package.json my/package.json
npm publish my --registry http://localhost:4873/
echo "publish success"
删除已发布项目
npm unpublish my@1.0.0 --registry http://localhost:4873/
淘宝镜像
https://registry.npmmirror.com/