在一次创建完 npm
私库之后,上传 npm
包没问题,但是下载一直出错。
老是请求一个旧的地址下载某个库,而那个地址已经停用了,因此请求很多次之后,npm 提示安装失败。
这个问题困扰了几乎一天的时间,网络搜索几乎也找不到合适的解决办法。
私库由 JFrog Artifactory 构建。
错误信息
项目安装私库包地址(这里为了方便显示的 127.0.0.1):
npm install test-cesium-api --registry http://127.0.0.1:8081/artifactory/api/npm/npm_virtual_webgis/
npm ERR! network request to http://某个域名.com:8081/repository/npm-public
部分报错信息(报错信息中这些包,私库的包根本没有引入,莫名其妙的下载):
461 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@mapbox\point-geometry' ]
462 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@mapbox\unitbezier' ]
463 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@protobufjs\aspromise' ]
464 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@protobufjs\base64' ]
465 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@protobufjs\eventemitter' ]
466 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@protobufjs\fetch' ]
467 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@protobufjs\codegen' ]
468 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@protobufjs\float' ]
469 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@protobufjs\inquire' ]
470 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@protobufjs\path' ]
471 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@protobufjs\pool' ]
472 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@protobufjs\utf8' ]
473 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@turf\along' ]
474 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@turf\area' ]
475 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@turf\angle' ]
476 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@turf\bbox' ]
477 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@turf\bbox-polygon' ]
478 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@turf\bbox-clip' ]
479 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@turf\bearing' ]
480 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@turf\bezier-spline' ]
481 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@turf\boolean-contains' ]
482 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@turf\boolean-clockwise' ]
483 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@turf\boolean-crosses' ]
484 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@turf\boolean-disjoint' ]
485 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@turf\boolean-equal' ]
486 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@turf\boolean-overlap' ]
487 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@turf\boolean-intersects' ]
488 silly reify mark retired [ 'C:\Users\Administrator\node_modules\@turf\boolean-parallel' ]
3351 verbose unfinished npm timer reifyNode:node_modules/arr-flatten 1687153998673
3352 verbose unfinished npm timer reifyNode:node_modules/aproba 1687153998673
3353 verbose unfinished npm timer reifyNode:node_modules/arr-diff 1687153998673
3354 verbose unfinished npm timer reifyNode:node_modules/accepts 1687153998673
3355 verbose unfinished npm timer reifyNode:node_modules/ansi-styles 1687153998673
3356 verbose unfinished npm timer reifyNode:node_modules/ansi-regex 1687153998673
3357 verbose unfinished npm timer reifyNode:node_modules/ansi-escapes 1687153998673
3358 verbose unfinished npm timer reifyNode:node_modules/ajv-keywords 1687153998673
3359 verbose unfinished npm timer reifyNode:node_modules/ajv-errors 1687153998675
3360 verbose unfinished npm timer reifyNode:node_modules/ajv 1687153998675
3361 verbose unfinished npm timer reifyNode:node_modules/acorn 1687153998675
3362 verbose code 1
3363 error A complete log of this run can be found in:
3363 error C:UsersAdministratorAppDataLocalnpm-cache_logs2023-06-19T05_53_16_173Z-debug-0.log
npm WARN deprecated @petamoriken/float16@1.1.1: critical bug fixed in v3.1.1
npm ERR! code ETIMEDOUT
npm ERR! syscall connect
npm ERR! errno ETIMEDOUT
npm ERR! network request to http://某个域名.com:8080/repository/npm-public/zrender/-/zrender-4.3.2.tgz failed, reason: connect ETIMEDOUT 111.164.191.6:21888
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersAdministratorAppDataLocalnpm-cache_logs2023-06-19T06_05_20_043Z-debug-0.log
试错过程
1. 重置 npm config 配置(cache、prefix、registry )
首先想到的是,npm 配置问题,导致请求莫名其妙的地址,于是尝试还原配置,结果无效。
2. 删除 C:UsersAdministrator.npmrc
由于提示被覆写,因此,将 .npmrc 删除,结果还是无效。
3. 清除缓存:执行:npm cache clean –force 报错
,于是执行:npm cache verify
经尝试,清除了本地缓存,也清除了服务端(JFrog Artifactory
)缓存,均不生效。
4. 卸载重装 npm 和 node
这回没其他办法了,只有卸载重装 npm 和 node 了。
本来想着可以使用 360 卸载,结果好像是绿色版,需要手动清理环境变量、注册表等,手动删除所有相关文件以及文件夹。
参考博客:
5. 全局搜索 package.json,并删除,执行安装,解决问题!
本来几乎要放弃了,后来一想,npm 安装是依据 package.json
的配置来下载安装的。
然后全局搜了一下 package.json 文件,发现 C:WindowsSystem32 下居然有一个 package.json 和 package–lock.json!!!
打开 package.json 和 package-lock.json
发现问题所在,原来这里边有之前下载私库的地址。
因此,每次下载私库,都会执行这个 package.json 去下载之前的私库,而那个私库的地址已经被弃用了,导致请求多次失败之后引起 npm 报错!!!
解决办法
弄清楚问题,解决就很简单了,删除 package.json 和 package-lock.json
。
执行 npm i 即可,会自动生成干净的 package 文件。
重新安装私库,成功!!!
原文地址:https://blog.csdn.net/linzi19900517/article/details/131286833
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_7547.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!