前端项目npm install报错解决的解决办法

报错问题一:

[root@spug-api spug_web]# npm install
npm WARN deprecated xterm@4.19.0: This package is now deprecated. Move to @xterm/xterm instead.
npm WARN deprecated workbox-google-analytics@4.3.1: It is not compatible with newer versions of GA starting with v4, as long as you are using GAv3 it should be ok, but the package is not longer being maintained
npm WARN deprecated w3c-hr-time@1.0.2: Use your platform's native performance.now() and performance.timeOrigin.
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm ERR! code ECONNREFUSED
npm ERR! syscall connect
npm ERR! errno ECONNREFUSED
npm ERR! FetchError: request to https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz failed, reason: connect ECONNREFUSED 104.16.3.35:443
npm ERR!     at ClientRequest.<anonymous> (/usr/local/node16/lib/node_modules/npm/node_modules/minipass-fetch/lib/index.js:110:14)
npm ERR!     at ClientRequest.emit (node:events:390:28)
npm ERR!     at TLSSocket.socketErrorListener (node:_http_client:447:9)
npm ERR!     at TLSSocket.emit (node:events:402:35)
npm ERR!     at emitErrorNT (node:internal/streams/destroy:157:8)
npm ERR!     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
npm ERR!     at processTicksAndRejections (node:internal/process/task_queues:83:21)
npm ERR!  FetchError: request to https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz failed, reason: connect ECONNREFUSED 104.16.3.35:443
npm ERR!     at ClientRequest.<anonymous> (/usr/local/node16/lib/node_modules/npm/node_modules/minipass-fetch/lib/index.js:110:14)
npm ERR!     at ClientRequest.emit (node:events:390:28)
npm ERR!     at TLSSocket.socketErrorListener (node:_http_client:447:9)
npm ERR!     at TLSSocket.emit (node:events:402:35)
npm ERR!     at emitErrorNT (node:internal/streams/destroy:157:8)
npm ERR!     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
npm ERR!     at processTicksAndRejections (node:internal/process/task_queues:83:21) {
npm ERR!   code: 'ECONNREFUSED',
npm ERR!   errno: 'ECONNREFUSED',
npm ERR!   syscall: 'connect',
npm ERR!   address: '104.16.3.35',
npm ERR!   port: 443,
npm ERR!   type: 'system'
npm ERR! }
npm ERR!
npm ERR! If you are behind a proxy, please make sure that the
npm ERR! 'proxy' config is set properly.  See: 'npm help config'

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2024-09-30T19_51_27_329Z-debug.log

报错问题二:

npm修改镜像源报错:"npm ERR! errno CERT_HAS_EXPIRED":

[root@spug-api spug_web]# npm config set registry https://registry.npm.taobao.org/

[root@spug-api spug_web]# npm install
npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated w3c-hr-time@1.0.2: Use your platform's native performance.now() and performance.timeOrigin.
npm WARN deprecated workbox-google-analytics@4.3.1: It is not compatible with newer versions of GA starting with v4, as long as you are using GAv3 it should be ok, but the package is not longer being maintained
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm WARN deprecated xterm@4.19.0: This package is now deprecated. Move to @xterm/xterm instead.
npm ERR! code CERT_HAS_EXPIRED
npm ERR! errno CERT_HAS_EXPIRED
npm ERR! request to https://registry.npm.taobao.org/yargs-parser/-/yargs-parser-13.1.2.tgz failed, reason: certificate has expired

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2024-09-30T20_07_55_345Z-debug.log

解决方案:

1.忽略ssl验证:

因为https://registry.npm.taobao.org/镜像源证书过期了,如果继续使用这个源,就忽略ssl验证

[root@spug-api spug_web]# npm config set strict-ssl false
[root@spug-api spug_web]# npm config set registry https://registry.npm.taobao.org/
[root@spug-api spug_web]# npm install

2.修改为新的淘宝源https://registry.npmirror.com:

[root@spug-api spug_web]# npm config set strict-ssl true
[root@spug-api spug_web]# npm config set registry https://registry.npmirror.com
[root@spug-api spug_web]# npm install
相关推荐
low神5 分钟前
React Native实现推送通知
前端·javascript·react native·react.js·前端面试题
等什么君!5 分钟前
复习HTML(基础)
前端·html
Engss5 分钟前
taro RN 左右滑动切换页面
前端·javascript·react.js·taro
MarisolHu36 分钟前
前端学习笔记-JS进阶篇-01
前端·javascript·笔记·学习
被迫学习Java2 小时前
前端工程化17-邂逅原生的ajax、跨域、JSONP
前端·ajax·okhttp
Justinc.3 小时前
CSS基础
前端·css
全栈练习生4 小时前
pnpm在monorepo架构下不能引用其他模块的问题
前端
CiL#7 小时前
css动态边框
前端·css
风清云淡_A7 小时前
uniapp中检测应用更新的两种方式-升级中心之uni-upgrade-center-app
前端·uni-app