在Node.js中安装ESLint时遭遇404错误求助
Node.js项目配置ESLint时npm 404错误解决办法
错误场景
执行npm init @eslint/config命令配置ESLint时,系统提示需要安装@eslint/create-config@0.4.6,确认后触发npm报错:
PS C:\notes-app-backend> npm init @eslint/config Need to install the following packages: @eslint/create-config@0.4.6 Ok to proceed? (y) y npm ERR! code E404 npm ERR! 404 Not Found - GET https://repo.huaweicloud.com/repository/npm/enquirer/-/enquirer-2.4.1.tgz npm ERR! 404 npm ERR! 404 'enquirer@https://repo.huaweicloud.com/repository/npm/enquirer/-/enquirer-2.4.1.tgz' is not in this registry. npm ERR! 404 npm ERR! 404 Note that you can also install from a npm ERR! 404 tarball, folder, http url, or git url. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\akhda\AppData\Local\npm-cache\_logs\2023-08-24T06_50_11_679Z-debug-0.log
核心原因是当前使用的华为云npm仓库未同步到enquirer@2.4.1版本,导致拉取依赖失败。
解决办法
临时切换至npm官方源执行配置命令
- 执行命令切换源:
npm config set registry https://registry.npmjs.org/ - 重新运行ESLint配置命令:
npm init @eslint/config - 配置完成后,若需切回华为云源,执行:
npm config set registry https://repo.huaweicloud.com/repository/npm/
- 执行命令切换源:
手动指定源安装依赖后再配置
直接用官方源安装@eslint/create-config:npm install @eslint/create-config@0.4.6 --registry=https://registry.npmjs.org/安装完成后运行:
npx @eslint/create-config完成ESLint配置检查华为云源的包同步状态
若必须使用华为云npm源,可确认该源是否已同步enquirer@2.4.1版本,若未同步,可等待源自动同步或联系管理员处理。
内容的提问来源于stack exchange,提问作者Febryan Akhdani
相关产品推荐
相关产品推荐

