资源官方:https://github.com/verdaccio/…参考:https://blog.csdn.net/yyzzhc9…参考:https://www.jianshu.com/p/16b…参考:https://www.jianshu.com/p/1d0…原来用sinopia搭建的私服,但sinopia两年年停止维护了,现在改为verdaccio。使用verdaccio也超级简单,只需几分钟就可以搭建一个私服,适合公司内部不对外的包的安装一:安装和配置A.安装$ yarn global add verdaccioyarn global v1.12.3[1/4] Resolving packages…[2/4] Fetching packages…[3/4] Linking dependencies…[4/4] Building fresh packages…success Installed “verdaccio@3.10.1” with binaries: - verdaccioDone in 52.10s.安装到了 C:\Users\Administrator\AppData\Local\Yarn\bin[我的是win10]B.测试随便建一个空目录测试,我当前工作目录是F:\youshengyouse\del3$ verdaccio warn — config file - C:\Users\Administrator.config\verdaccio\config.yaml warn — Plugin successfully loaded: htpasswd warn — Plugin successfully loaded: audit warn — http address - http://localhost:4873/ - verdaccio/3.10.1在浏览器输入http://localhost:4873/,结果如下二:添加用户另开一个命令行窗口,原来的verdaccio仍在运行$ npm adduser –registry http://localhost:4873Username: abcdPassword: qwerEmail: (this IS public) a@163.comLogged in as abcd on http://localhost:4873/.三:发布私包当前工作目录:要发布哪个包,当前目录切换到包根目录下$ npm publish –registry http://localhost:4873> gatsby2-cli@1.0.0 prepare .> cross-env NODE_ENV=production npm run build> gatsby2-cli@1.0.0 build F:\youshengyouse\frontend\packages\gatsby\packages\gatsby2-cli> babel src –out-dir lib –ignore **/__tests__Successfully compiled 6 files with Babel.npm noticenpm notice package: gatsby2-cli@1.0.0npm notice === Tarball Contents ===npm notice 1.8kB package.jsonnpm notice 7.4kB CHANGELOG.mdnpm notice 3.3kB README.mdnpm notice 9.4kB lib/create-cli.jsnpm notice 2.7kB lib/index.jsnpm notice 4.7kB lib/init-starter.jsnpm notice 2.0kB lib/reporter/errors.jsnpm notice 3.1kB lib/reporter/index.jsnpm notice 4.0kB lib/reporter/prepare-stack-trace.jsnpm notice === Tarball Details ===npm notice name: gatsby2-clinpm notice version: 1.0.0npm notice package size: 11.0 kBnpm notice unpacked size: 38.3 kBnpm notice shasum: 64c9c47b81610731e559bc33f86aa02f87155656npm notice integrity: sha512-vhroNpnWCwivE[…]8hAg+z6SPOeyw==npm notice total files: 9npm notice+ gatsby2-cli@1.0.0现在刷新http://localhost:4873/#/就可以看到刚才发布的包问题:本地安装的包放在哪里了呢?四:安装包npm set registry http://localhost:4873/$ npm init # 如果没有package.json文件得先建$ yarn add gatsby2-cli发现gatsby2-cli是在本地的,其余的依赖还是从npmjs.com仓库中安装的