NPM错误:修复安装NPM包的上游依赖冲突(云功能)

Weg*_*ege 6 node.js npm firebase google-cloud-functions

我刚刚用这个函数更新了 firebase 函数npm i firebase-functions@latest,并更新了npm install -g firebase-tools。突然之间,我无法在 部署我的所有功能firebase deploy --only functions。我遇到了所有这些错误:

Build failed: npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: firebase-functions-test@0.2.3
npm ERR! Found: firebase-functions@4.0.0-rc.0
npm ERR! node_modules/firebase-functions
npm ERR!   firebase-functions@"^4.0.0-rc.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer firebase-functions@">=2.0.0" from firebase-functions-test@0.2.3
npm ERR! node_modules/firebase-functions-test
npm ERR!   dev firebase-functions-test@"^0.2.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: firebase-functions@3.24.1
npm ERR! node_modules/firebase-functions
npm ERR!   peer firebase-functions@">=2.0.0" from firebase-functions-test@0.2.3
npm ERR!   node_modules/firebase-functions-test
npm ERR!     dev firebase-functions-test@"^0.2.0" 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.
Run Code Online (Sandbox Code Playgroud)

有人知道发生了什么事吗?我在stackoverflow上尝试过这个功能,但一点运气都没有。npm install --legacy-peer-deps请帮我!我这两天都是这样!

函数图像

函数图像

小智 2

您遇到的问题是firebase-functions-test指定它需要 version 的 firebase-functions >=2.0.0。npm 将此解释为“大于或等于 2.0.0 的稳定版本”。这意味着诸如3.24.13.0.0、 之类的版本2.3.1都有效,但诸如4.0.0-rc.0或 之类的假设5.9.3-beta则无效。

当您运行 时npm i firebase-functions@latest,它会获取开发人员标记为“最新”的版本,即4.0.0-rc-0,它不满足上述约束。

我建议显式安装稳定版本 ( npm install firebase-functions@3.24.1),或者 - 如果您有权访问firebase-functions-test- 修改该包package.json以指定"firebase-functions": ">=2.0.0 || 4.0.0-rc.0".

查看npm semver 计算器以查看哪些说明符与哪些版本匹配。