当前位置: 代码网 > it编程>前端脚本>Node.js > npm镜像源证书过期的问题解决

npm镜像源证书过期的问题解决

2024年09月12日 Node.js 我要评论
failed to check for updates 问题错误描述如上检查完node,vue,npm的版本后都没啥问题,尝试更新脚手架使用指令#npm脚手架更新pnpm update -g @vue

failed to check for updates 问题

错误描述如上

检查完 node,vue,npm 的版本后都没啥问题,尝试更新脚手架

使用指令

#npm脚手架更新

pnpm update -g @vue/cli

出现问题如下:

err_pnpm_no_pkg_manifest

这个是报错类型编号

在这里插入图片描述

这个报错是没有找到 package.json 的文件,我当时没仔细看,就尝试重新安装 pnpm

#pnpm更新安装

npm install pnpm -g

出现报错

npm err! code cert_has_expired
npm err! errno cert_has_expired
npm err! request to https://registry.npm.taobao.org/pnpm failed, reason: certificate has expired

npm err! log files were not written due to an error writing to the directory: d:\nodejavascript\node_cache\_logs
npm err! you can rerun the command with `--loglevel=verbose` to see the logs in your terminal

在这里已经很明显了,报错提示是 #reason:certificate_has_expired 就是说目前我的镜像网站证书过期了,连淘宝自己提供的镜像源网站都不去管管证书的嘛??(来自我复盘的吐槽)

当时认为是不是自己的问题,进行 npm 缓存清除操作,

npm缓存清除指令

npm cache clean --force

出现第二个报错

ps d:\front-end\untitled2> npm cache clean --force
npm warn using --force recommended protections disabled.
npm err! code eperm
npm err! syscall rmdir
npm err! path d:\nodejavascript\node_cache\_cacache\tmp
npm err! errno -4048
npm err! error: eperm: operation not permitted, rmdir 'd:\nodejavascript\node_cache\_cacache\tmp'
npm err!   errno: -4048,
npm err!   code: 'eperm',
npm err!   syscall: 'rmdir',
npm err!   path: 'd:\\nodejavascript\\node_cache\\_cacache\\tmp'
npm err! }
npm err!
npm err! the operation was rejected by your operating system.
npm err! it's possible that the file was already in use (by a text editor or antivirus),
npm err! or that you lack permissions to access it.
npm err!
npm err! permissions of the file and its containing directories, or try running
npm err! the command again as root/administrator.

npm err! log files were not written due to an error writing to the directory: d:\nodejavascript\node_cache\_logs
npm err! you can rerun the command with `--loglevel=verbose` to see the logs in your terminal

其实这个也说的很清楚,error:eperm:operation not permitted,rmdir ‘d:\nodejavascript\node_cache\_cacache\tmp’

就是说没有权限删除,这个问题一般有几种解决思路

权限不足导致删除不了解决方案

  • 如果是在c盘的文件遇到权限不足,建议移出c盘,因为c盘的权限是一个迷,很容易出现奇奇怪怪的权限问题
  • 如果是在其他盘,直接开管理员权限运行就可以了

之后明白可能是证书和权限的问题,就打算随便执行一下依赖更新操作,检验一下是否可用

#npm依赖更新指令

npm install

然后给我直接报错了 #没有package的json文件报错

ps d:\front-end\untitled2> npm install
npm err! code enoent
npm err! syscall open
npm err! path d:\front-end\untitled2/package.json
npm err! errno -4058
npm err! enoent enoent: no such file or directory, open 'd:\front-end\untitled2\package.json'
npm err! enoent this is related to npm not being able to find a file.
npm err! enoent

npm err! log files were not written due to an error writing to the directory: d:\nodejavascript\node_cache\_logs
npm err! you can rerun the command with `--loglevel=verbose` to see the logs in your terminal
wrote to d:\front-end\untitled2\package.json:

npm创建基础配资文件

npm init -y

这样就默认创建了一个简单的 package.json 文件

ok! 到此为止,就基本上将边角问题解决了,后续考虑解决问题是否应该切换一个数据源的问题

#npm检查设置远程仓库指令

npm config get registry

得到域名

https://npm.taobao.org

去网上搜,淘宝那个npm 改名了!!!

https://npmmirror.com/

最新的是这个,我真的心情复杂。

设置一下全局镜像源配置就行了,最后完成目的的指令是

npm config set registry=https://npmmirror.com/

如果出现以下这种错误,就是说明镜像源太落后了,不匹配

ps d:\front-end\untitled3> npm install
npm err! code etarget
npm err! notarget no matching version found for @vue/server-renderer@3.4.21.
npm err! notarget in most cases you or one of your dependencies are requesting
npm err! notarget a package version that doesn't exist.
npm err! a complete log of this run can be found in: d:\nodejavascript\node_cache\_logs\2024-02-29t04_10_05_694z-debug-0.log
ps d:\front-end\untitled3> npm config set      
npm err! code eusage
npm err!

主要从这几句话可以看出 notarget no matching version found for @vue/server-renderer@3.4.21

这个是之前我换华为云的镜像服务器之后出现的问题,最后实在不行了,换回了 https://npmmirror.com/ 这个域名

从此,解决 npm 无法使用问题

到此这篇关于npm镜像源证书过期的问题解决的文章就介绍到这了,更多相关npm镜像源证书过期内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网!

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com