如何在部署 Next.js 13 应用程序到 Vercel 时修复这个依赖错误?

huangapple go评论80阅读模式
英文:

How can I fix this dependancy error when deploying a nextjs 13 app with vercel?

问题

It looks like you're encountering an issue while deploying your Next.js 13 app with Vercel. The error message you provided indicates a problem with resolving dependencies related to ESLint.

Here's the translated error message and some potential steps you can take to resolve it:

我正在尝试使用Vercel部署我的Next.js 13应用程序,但在部署时出现了错误。在VSCode中,我已经运行了代码检查,并没有返回任何问题。还在VSCode中运行了 'npm run build',一切正常。

...
[14:58:04.074] npm ERR! code ERESOLVE
[14:58:04.077] npm ERR! ERESOLVE 无法解析
[14:58:04.077] npm ERR! 
[14:58:04.077] npm ERR! 在解析时出现了问题:eslint-config-next@12.0.4
[14:58:04.077] npm ERR! 找到:eslint@8.44.0
[14:58:04.077] npm ERR! node_modules/eslint
[14:58:04.077] npm ERR!   eslint@ "8.44.0" 来自根项目
[14:58:04.078] npm ERR!   peer eslint@ "^6.0.0 || ^7.0.0 || >=8.0.0" 来自 @eslint-community/eslint-utils@4.4.0
[14:58:04.078] npm ERR!   node_modules/@eslint-community/eslint-utils
[14:58:04.078] npm ERR!     @eslint-community/eslint-utils@ "^4.2.0" 来自 eslint@8.44.0
[14:58:04.078] npm ERR!   5 更多 (eslint-import-resolver-typescript,...)
[14:58:04.078] npm ERR! 
[14:58:04.078] npm ERR! 无法解析依赖项:
[14:58:04.078] npm ERR! peer eslint@ "^7.23.0" 来自 eslint-config-next@12.0.4
[14:58:04.078] npm ERR! node_modules/eslint-config-next
[14:58:04.078] npm ERR!   eslint-config-next@ "^12.0.4" 来自根项目
[14:58:04.078] npm ERR! 
[14:58:04.078] npm ERR! 冲突的 peer 依赖关系:eslint@7.32.0
[14:58:04.078] npm ERR! node_modules/eslint
[14:58:04.078] npm ERR!   peer eslint@ "^7.23.0" 来自 eslint-config-next@12.0.4
[14:58:04.078] npm ERR!   node_modules/eslint-config-next
[14:58:04.078] npm ERR!     eslint-config-next@ "^12.0.4" 来自根项目
[14:58:04.079] npm ERR! 
[14:58:04.079] npm ERR! 修复上游依赖项冲突,或使用 --force 或 --legacy-peer-deps 重新运行此命令
[14:58:04.079] npm ERR! 来接受不正确(可能是损坏的)的依赖项解析。
[14:58:04.079] npm ERR! 
[14:58:04.079] npm ERR! 完整报告请参见:
[14:58:04.080] npm ERR! /vercel/.npm/_logs/2023-07-31T13_58_03_754Z-eresolve-report.txt
[14:58:04.080] 
[14:58:04.080] npm ERR! 该运行的完整日志可以在下面找到:
[14:58:04.080] npm ERR!     /vercel/.npm/_logs/2023-07-31T13_58_03_754Z-debug-0.log
[14:58:04.093] 错误:命令 "npm install" 退出代码为 1

To resolve this issue, you can try the following steps:

  1. Force Install Dependencies: Run the npm install command with the --force flag or --legacy-peer-deps to accept the potentially broken dependency resolution. This might help resolve the conflict.

  2. Check Package Versions: Review your project's package.json file and ensure that the versions of ESLint-related packages are compatible. You may need to adjust the versions to match or resolve the conflict manually.

  3. Update ESLint Configuration: If possible, update your ESLint configuration in your project to match the version of ESLint you have installed. This might involve adjusting the rules and settings in your .eslintrc file.

  4. Clear NPM Cache: Sometimes, issues can be related to the npm cache. You can try clearing the npm cache by running npm cache clean -f and then running npm install again.

Remember to make backups or commit your changes if you decide to make any modifications to your project's configuration files.

英文:

I am trying to deploy my NextJS 13 app with vercel, but I get this error on deploying. In vscode, I have ran the linting and it returned no problems. Also did 'npm run build' in vscode which worked fine.

...
[14:58:01.978] Previous build cache not available
[14:58:02.279] Cloning completed: 593.19ms
[14:58:02.615] Running "vercel build"
[14:58:03.127] Vercel CLI 31.1.1
[14:58:03.363] Installing dependencies...
[14:58:04.074] npm ERR! code ERESOLVE
[14:58:04.077] npm ERR! ERESOLVE could not resolve
[14:58:04.077] npm ERR! 
[14:58:04.077] npm ERR! While resolving: eslint-config-next@12.0.4
[14:58:04.077] npm ERR! Found: eslint@8.44.0
[14:58:04.077] npm ERR! node_modules/eslint
[14:58:04.077] npm ERR!   eslint@"8.44.0" from the root project
[14:58:04.078] npm ERR!   peer eslint@"^6.0.0 || ^7.0.0 || >=8.0.0" from @eslint-community/eslint-utils@4.4.0
[14:58:04.078] npm ERR!   node_modules/@eslint-community/eslint-utils
[14:58:04.078] npm ERR!     @eslint-community/eslint-utils@"^4.2.0" from eslint@8.44.0
[14:58:04.078] npm ERR!   5 more (eslint-import-resolver-typescript, ...)
[14:58:04.078] npm ERR! 
[14:58:04.078] npm ERR! Could not resolve dependency:
[14:58:04.078] npm ERR! peer eslint@"^7.23.0" from eslint-config-next@12.0.4
[14:58:04.078] npm ERR! node_modules/eslint-config-next
[14:58:04.078] npm ERR!   eslint-config-next@"^12.0.4" from the root project
[14:58:04.078] npm ERR! 
[14:58:04.078] npm ERR! Conflicting peer dependency: eslint@7.32.0
[14:58:04.078] npm ERR! node_modules/eslint
[14:58:04.078] npm ERR!   peer eslint@"^7.23.0" from eslint-config-next@12.0.4
[14:58:04.078] npm ERR!   node_modules/eslint-config-next
[14:58:04.078] npm ERR!     eslint-config-next@"^12.0.4" from the root project
[14:58:04.079] npm ERR! 
[14:58:04.079] npm ERR! Fix the upstream dependency conflict, or retry
[14:58:04.079] npm ERR! this command with --force or --legacy-peer-deps
[14:58:04.079] npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
[14:58:04.079] npm ERR! 
[14:58:04.079] npm ERR! 
[14:58:04.080] npm ERR! For a full report see:
[14:58:04.080] npm ERR! /vercel/.npm/_logs/2023-07-31T13_58_03_754Z-eresolve-report.txt
[14:58:04.080] 
[14:58:04.080] npm ERR! A complete log of this run can be found in:
[14:58:04.080] npm ERR!     /vercel/.npm/_logs/2023-07-31T13_58_03_754Z-debug-0.log
[14:58:04.093] Error: Command "npm install" exited with 1

I have tried installing next lint again with npm but that has made no difference.

答案1

得分: 0

  1. 前往 Vercel 项目的设置页面
  2. 在左侧菜单中选择 "General",然后滚动到 "Build & Development Settings"
  3. 打开 "install command" 的 "override" 开关
  4. 在输入框中写入 npm install --legacy-peer-deps
英文:
  1. Go to your project's settings on vercel
  2. Choose "General" on left menu and scroll to "Build & Development Settings"
  3. Turn the "override" on for "install command"
  4. Write npm install --legacy-peer-deps in the input.

huangapple
  • 本文由 发表于 2023年7月31日 22:05:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/76804408.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定