当我使用firebase deploy --only functions:nextServer
部署firebase函数时,出现如下错误:
✔ functions: Finished running predeploy script.
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i functions: ensuring required API cloudbuild.googleapis.com is enabled...
i artifactregistry: ensuring required API artifactregistry.googleapis.com is enabled...
✔ functions: required API cloudfunctions.googleapis.com is enabled
✔ artifactregistry: required API artifactregistry.googleapis.com is enabled
✔ functions: required API cloudbuild.googleapis.com is enabled
i functions: preparing codebase default for deployment
i functions: Loaded environment variables from .env.
i functions: preparing . directory for uploading...
i functions: packaged /Users/tony/programming/options-outcry (87.22 MB) for uploading
✔ functions: . folder uploaded successfully
i functions: updating Node.js 16 function nextServer(us-central1)...
Build failed: npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @mui/styles@5.10.3
npm ERR! Found: @types/react@18.0.17
npm ERR! node_modules/@types/react
npm ERR! dev @types/react@"18.0.17" from the root project
npm ERR! peerOptional @types/react@"^17.0.0 || ^18.0.0" from @mui/base@5.0.0-alpha.95
npm ERR! node_modules/@mui/base
npm ERR! @mui/base@"5.0.0-alpha.95" from @mui/material@5.10.3
npm ERR! node_modules/@mui/material
npm ERR! @mui/material@"^5.10.0" from the root project
npm ERR! 1 more (@mui/icons-material)
npm ERR! 10 more (@mui/icons-material, @mui/material, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional @types/react@"^17.0.0" from @mui/styles@5.10.3
npm ERR! node_modules/@mui/styles
npm ERR! @mui/styles@"^5.9.3" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @types/react@17.0.49
npm ERR! node_modules/@types/react
npm ERR! peerOptional @types/react@"^17.0.0" from @mui/styles@5.10.3
npm ERR! node_modules/@mui/styles
npm ERR! @mui/styles@"^5.9.3" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /www-data-home/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /www-data-home/.npm/_logs/2022-09-04T21_53_24_874Z-debug-0.log; Error ID: beaf8772
我搜索了一般情况下如何修复ERESOLVE
错误,大多数答案告诉我将--legacy-peer-deps
标志添加到npm install
命令中。
然而,这里发生的安装发生在firebase函数的部署过程中,我还没有找到任何允许我添加这个标志的东西(通过firebase.json
或任何其他方法)。
如何修复这个仅在部署到firebase时发生的构建错误?
1条答案
按热度按时间owfi6suc1#
我遇到了这个问题,并通过在
firebase.json
的"functions"
部分中添加npm标志来解决它: