淘宝源过期的问题
问题背景: electron+vue3的一个项目,按照平常的启动项目的方式,出现以下报错:
关键信息:certificate has expired
FetchError: request to https://registry.npm.taobao.org/brace-expansion failed, reason: certificate has expired
npm WARN old lockfile at ClientRequest.<anonymous> (/Users/a1/.nvm/versions/node/v17.9.1/lib/node_modules/npm/node_modules/minipass-fetch/lib/index.js:130:14)
npm WARN old lockfile at ClientRequest.emit (node:events:527:28)
npm WARN old lockfile at TLSSocket.socketErrorListener (node:_http_client:454:9)
npm WARN old lockfile at TLSSocket.emit (node:events:539:35)
npm WARN old lockfile at emitErrorNT (node:internal/streams/destroy:164:8)
npm WARN old lockfile at emitErrorCloseNT (node:internal/streams/destroy:129:3)
npm WARN old lockfile at processTicksAndRejections (node:internal/process/task_queues:83:21)
npm WARN old lockfile Could not fetch metadata for brace-expansion@1.1.11 FetchError: request to https://registry.npm.taobao.org/brace-expansion failed, reason: certificate has expired
npm WARN old lockfile at ClientRequest.<anonymous> (/Users/a1/.nvm/versions/node/v17.9.1/lib/node_modules/npm/node_modules/minipass-fetch/lib/index.js:130:14)
npm WARN old lockfile at ClientRequest.emit (node:events:527:28)
npm WARN old lockfile at TLSSocket.socketErrorListener (node:_http_client:454:9)
npm WARN old lockfile at TLSSocket.emit (node:events:539:35)
npm WARN old lockfile at emitErrorNT (node:internal/streams/destroy:164:8)
npm WARN old lockfile at emitErrorCloseNT (node:internal/streams/destroy:129:3)
npm WARN old lockfile at processTicksAndRejections (node:internal/process/task_queues:83:21) {
npm WARN old lockfile code: 'CERT_HAS_EXPIRED',
npm WARN old lockfile errno: 'CERT_HAS_EXPIRED',
npm WARN old lockfile type: 'system'
npm WARN old lockfile }
npm WARN old lockfile FetchError: request to https://registry.npm.taobao.org/eslint-plugin-import failed, reason: certificate has expired
npm WARN old lockfile at ClientRequest.<anonymous> (/Users/a1/.nvm/versions/node/v17.9.1/lib/node_modules/npm/node_modules/minipass-fetch/lib/index.js:130:14)
尝试过的操作: 清理并重新安装 node_modules:
- 删除
node_modules文件夹:rm -rf node_modules - 清除 npm 缓存:
npm cache clean --force - 重新安装依赖:
npm install
都不能解决
解决方案:
1.更换淘宝源码 npm config delete registry 或者 npm config set registry registry.npmjs.org/
或者在项目中的.npmrc的文件中更换 registry=registry.npmmirror.com
解决方案:
遇到 "Permission denied" 错误通常意味着你没有足够的权限来执行
electron-rebuild 命令。这种问题在 macOS 中相对常见,尤其是当你尝试运行安装在本地项目中的脚本时。以下是一些解决方案:
-
使用
sudo执行命令:你可以尝试在命令前加上sudo来以超级用户身份运行,例如sudo npm run dev。这将要求你输入你的计算机用户密码。但请注意,频繁使用sudo运行 npm 命令可能会带来安全风险,因为它允许脚本以管理员权限运行,这种方式不生效 -
更改文件权限:你可以尝试更改
electron-rebuild脚本的权限,使其可执行。在终端中运行以下命令:chmod +x /Users/a1/Desktop/ys/ly/ly-lr-client/node_modules/.bin/electron-rebuild这将给予该脚本执行权限。改解决方式,生效了