windows下利用verdaccio私服让npm构建速度上来

一.verdaccio的准备

上一篇文章,我写了的,看这里。windows下使用verdaccio构建npm私服环境-CSDN博客

二.用nrm实现npm源管理

虽然英语不好,我猜这个工具的缩写的意思是npm resource manage,哈哈。

1.安装nrm

输入npm install -g nrm

结果,我遇到了问题,如下:

C:\Users\Dell>npm install -g nrm
npm ERR! code CERT_HAS_EXPIRED
npm ERR! errno CERT_HAS_EXPIRED
npm ERR! request to https://registry.npm.taobao.org/nrm failed, reason: certificate has expired

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Dell\AppData\Local\npm-cache\_logs\2024-02-02T02_05_58_445Z-debug-0.log

我之前好像设置了npm的源为淘宝的,现在提示过期了。估计像之前的maven代理地址,需要每个人登录去获取自己的地址。换华为地址吧

npm install -g nrm --registry=https://mirrors.huaweicloud.com/repository/npm

安装成功了,如下:

C:\Users\Dell>npm install -g nrm --registry=https://mirrors.huaweicloud.com/repository/npm

added 17 packages in 13s

4 packages are looking for funding
  run `npm fund` for details
npm notice
npm notice New major version of npm available! 8.15.0 -> 10.4.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.4.0
npm notice Run npm install -g npm@10.4.0 to update!
npm notice

2.查看当前npm源地址

输入 nrm ls,结果如下:

C:\Users\Dell>nrm ls
  npm ---------- https://registry.npmjs.org/
  yarn --------- https://registry.yarnpkg.com/
  tencent ------ https://mirrors.cloud.tencent.com/npm/
  cnpm --------- https://r.cnpmjs.org/
  taobao ------- https://registry.npmmirror.com/
  npmMirror ---- https://skimdb.npmjs.com/registry/

3.添加npm私库

nrm add localnpm http://10.1.230.123:4873

然后再看看,我们的私库地址就在里面了。

C:\Users\Dell>nrm ls
  npm ---------- https://registry.npmjs.org/
  yarn --------- https://registry.yarnpkg.com/
  tencent ------ https://mirrors.cloud.tencent.com/npm/
  cnpm --------- https://r.cnpmjs.org/
  taobao ------- https://registry.npmmirror.com/
  npmMirror ---- https://skimdb.npmjs.com/registry/
  localnpm ----- http://10.1.230.123:4873/

4.指定使用私库

输入nrm use localnpm,结果是指定成功,如下:

C:\Users\Dell>nrm use localnpm
 SUCCESS  The registry has been changed to 'localnpm'.

5.通过nrm查看默认npm源

再输入nrm ls。我们的localnpm前面多了一个"*",代表它是默认的源了。

C:\Users\Dell\qiankunbag-vue>nrm ls
  npm ---------- https://registry.npmjs.org/
  yarn --------- https://registry.yarnpkg.com/
  tencent ------ https://mirrors.cloud.tencent.com/npm/
  cnpm --------- https://r.cnpmjs.org/
  taobao ------- https://registry.npmmirror.com/
  npmMirror ---- https://skimdb.npmjs.com/registry/
* localnpm ----- http://10.1.230.123:4873/

三.构建测试

先拿之前的前端代码,构建试试

C:\Users\Dell\qiankunbag-vue>npm install
*********中间省略了哦
added 2012 packages in 45s

45秒,虽然还是有点慢,但我可以接受了。

通过私库上的日志输出,我们也可以看到,我本次构建是访问了私服的。虽然有的请求有问题,暂时不去深究哈,构建成功就行!(我本机的ip就是10.2.20.73。你不会不知道ipconfig查看ip吧?)

 http --- 200, req: 'GET https://mirrors.huaweicloud.com/repository/npm/@soda%2Ffriendly-errors-webpack-plugin' (streaming)
 http --- 200, req: 'GET https://mirrors.huaweicloud.com/repository/npm/@soda%2Ffriendly-errors-webpack-plugin', bytes: 0/16696
 http <-- 304, user: null(10.2.20.73), req: 'GET /@soda%2ffriendly-errors-webpack-plugin', bytes: 0/0
 info <-- 10.2.20.73 requested 'POST /-/npm/v1/security/advisories/bulk'
 http <-- 200, user: null(10.2.20.73), req: 'POST /-/npm/v1/security/advisories/bulk', bytes: 11863/0
 warn --- could not fetch audit: FetchError: request to https://registry.npmjs.org/-/npm/v1/security/advisories/bulk failed, reason:
 http <-- 500, user: null(10.2.20.73), req: 'POST /-/npm/v1/security/advisories/bulk', bytes: 11863/0
 info <-- 10.2.20.73 requested 'POST /-/npm/v1/security/audits/quick'
 http <-- 200, user: null(10.2.20.73), req: 'POST /-/npm/v1/security/audits/quick', bytes: 667/0
 warn --- could not fetch audit: FetchError: request to https://registry.npmjs.org/-/npm/v1/security/audits/quick failed, reason:
 http <-- 500, user: null(10.2.20.73), req: 'POST /-/npm/v1/security/audits/quick', bytes: 667/0
相关推荐
Amd7942 小时前
Nuxt.js 应用中的 webpack:compile 事件钩子
webpack·自定义·编译·nuxt.js·构建·钩子·逻辑
Ztiddler6 小时前
【npm设置代理-解决npm网络连接error network失败问题】
前端·后端·npm·node.js·vue
三天不学习7 小时前
前端工程化-node/npm/babel/polyfill/webpack 一文速通
前端·webpack·npm
水w1 天前
Node.js windows版本 下载和安装(详细步骤)
开发语言·前端·windows·npm·node
guokanglun1 天前
npm镜像查看和修改
前端·npm·node.js
Amd7941 天前
Nuxt.js 应用中的 webpack:configResolved事件钩子
webpack·自定义·开发·配置·nuxt.js·构建·钩子
你的代码我的心1 天前
解决 npm xxx was blocked, reason: xx bad guy, steal env and delete files
npm
明天最后1 天前
由于Two-Factor Authentication导致github发布npm包失败
前端·npm·github
平芜尽处是春山-2 天前
vue3项目执行npm install下载依赖报错问题排查方法
前端·npm·node.js
飞翔的佩奇3 天前
maven手动上传jar到私服仓库:mvn deploy:deploy-file命令
java·maven·jar·仓库·私服·deploy