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

 更新时间:2024年07月07日 11:26:24   作者:枫飘长安  
因为npm官方镜像在国内访问很慢,我们基本上都会选择切换到国内的一些npm镜像,本文主要介绍了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 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镜像源证书过期内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

相关文章

  • 详解node登录接口之密码错误限制次数(含代码)

    详解node登录接口之密码错误限制次数(含代码)

    这篇文章主要介绍了nodejs登录接口之密码错误限制次数(含代码),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2019-10-10
  • nodeJS代码实现计算交社保是否合适

    nodeJS代码实现计算交社保是否合适

    本文通过nodejs的一个具体示例来对比分析现阶段我们交社保合不合适,主要是对nodejs的一个小的应用,当然大家也可以改成其他语言的,程序猿们,来算算吧。
    2015-03-03
  • 详解autojs的nodejs编写UI技巧示例

    详解autojs的nodejs编写UI技巧示例

    这篇文章主要为大家介绍了autojs的nodejs编写UI技巧示例详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2023-01-01
  • Node.js中 __dirname 的使用介绍

    Node.js中 __dirname 的使用介绍

    这篇文章主要给大家介绍了关于Node.js中 __dirname使用的相关资料,文中介绍的非常详细,对大家具有一定的参考学习价值,需要的朋友们下面来一起看看吧。
    2017-06-06
  • 使用Redis和Node.js来开发简单的实时聊天功能

    使用Redis和Node.js来开发简单的实时聊天功能

    在众多实时通信的技术中,Redis和Node.js的结合是一种非常强大和流行的选择,Redis是一种高性能的键值存储数据库,而Node.js是一个基于事件驱动的JavaScript运行时环境,两者的结合可以轻松实现实时聊天功能,本文将指导您使用Redis和Node.js来开发一个简单的实时聊天功能
    2024-08-08
  • NPM命令运行报错:npm v10.2.4 is known not to run on Node.js v14.21.1解决办法

    NPM命令运行报错:npm v10.2.4 is known not to run on Node.js

    这篇文章主要给大家介绍了关于NPM命令运行报错:npm v10.2.4 is known not to run on Node.js v14.21.1的解决办法,文中将解决办法介绍的非常详细,需要的朋友可以参考下
    2024-01-01
  • Mac中安装nvm的教程分享

    Mac中安装nvm的教程分享

    下面小编就为大家分享一篇Mac中安装nvm的教程,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2017-12-12
  • 使用socket.io制做简易WEB聊天室

    使用socket.io制做简易WEB聊天室

    这篇文章主要为大家详细介绍了使用socket.io制做简易WEB聊天室,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2018-01-01
  • nodejs取得当前执行路径的方法

    nodejs取得当前执行路径的方法

    今天小编就为大家分享一篇nodejs取得当前执行路径的方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2018-05-05
  • 浅谈Node.js爬虫之网页请求模块

    浅谈Node.js爬虫之网页请求模块

    本篇文章主要介绍了浅谈Node.js爬虫之网页请求模块,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2018-01-01

最新评论