npm镜像源证书过期的问题解决
作者:枫飘长安
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 expirednpm 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! enoentnpm 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镜像源证书过期内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!