[英]Build failed: npm ERR! @google-cloud/firestore not accessible from firebase-admin
I trying to deploy my cloud function, but some errors are showing up:我试图部署我的云功能,但出现了一些错误:
The error below is from Google Cloud Panel下面的错误来自谷歌云面板
Build failed: npm ERR!构建失败:npm ERR! @google-cloud/firestore not accessible from firebase-admin @google-cloud/firestore 无法从 firebase-admin 访问
The error below is from Firebase functions monitoring:以下错误来自 Firebase 功能监控:
"status":{"code":3,"message":"Build failed: npm ERR! @google-cloud/firestore not accessible from firebase-admin\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /www-data-home/.npm/_logs/2022-07-04T19_57_48_524Z-debug.log; Error ID: beaf8772"}
The error below is from terminal:以下错误来自终端:
Functions deploy had errors with the following functions:
api(us-central1)
i functions: cleaning up build files...
Error: There was an error deploying functions:
- Error Failed to update function api in region us-central1
The error below is from firestore-debug.log:下面的错误来自 firestore-debug.log:
[info] ✔ functions: functions folder uploaded successfully
[info] i functions: updating Node.js 10 function api(us-central1)...
[debug] [2022-07-04T19:53:55.051Z] [update-us-central1-api] Retrying task index 0
[debug] [2022-07-04T19:54:25.656Z] [update-us-central1-api] Retrying task index 0
[debug] [2022-07-04T19:54:26.646Z] Got source token undefined for region us-central1
[debug] [2022-07-04T19:54:49.329Z] Total Function Deployment time: 56913
[debug] [2022-07-04T19:54:49.329Z] 2 Functions Deployed
[debug] [2022-07-04T19:54:49.329Z] 2 Functions Errored
[debug] [2022-07-04T19:54:49.329Z] 0 Function Deployments Aborted
[debug] [2022-07-04T19:54:49.329Z] Average Function Deployment time: 45578
[info]
[info] Functions deploy had errors with the following functions:
api(us-central1)
[debug] [2022-07-04T19:54:50.026Z] Missing URI for HTTPS function in printTriggerUrls. This shouldn't happen
[info] i functions: cleaning up build files...
What is the real source of the error and how to solve it?错误的真正来源是什么以及如何解决?
I appreciate any help!我很感激任何帮助!
EDIT编辑
I tried to edit the function directly from the Google Cloud Panel, but the same error is showing up.我尝试直接从 Google Cloud Panel 编辑该功能,但出现了同样的错误。
Below is the reproducible code:以下是可重现的代码:
const functions = require('firebase-functions');
const express = require('express');
const app = express();
const admin = require('firebase-admin');
admin.initializeApp();
app.post('/test', (req, res) => {
res.status(200).send({ msg: "hello world" })
});
exports.api = functions.https.onRequest(app);
Below is the node and npm versions:以下是 node 和 npm 版本:
node --version
v14.16.0
npm --version
7.19.1
Below is the file package.json下面是文件 package.json
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "eslint",
"serve": "firebase serve --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "10"
},
"dependencies": {
"@google-cloud/pubsub": "^2.17.0",
"axios": "^0.21.1",
"express": "^4.17.1",
"firebase-admin": "^9.11.1",
"firebase-functions": "^3.3.0",
"lodash": "^4.17.21"
},
"devDependencies": {
"eslint": "^5.12.0",
"eslint-plugin-promise": "^4.0.1",
"firebase-functions-test": "^0.1.6"
},
"private": true
}
I also tried to update the firebase-admin and firebase-functions packages, but no success.我还尝试更新 firebase-admin 和 firebase-functions 软件包,但没有成功。
npm install --legacy-peer-deps
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: undefined,
npm WARN EBADENGINE required: { node: '10' },
npm WARN EBADENGINE current: { node: 'v14.16.0', npm: '7.19.1' }
npm WARN EBADENGINE }
added 20 packages, removed 21 packages, changed 20 packages, and audited 351 packages in 19s
10 packages are looking for funding
run `npm fund` for details
9 vulnerabilities (3 moderate, 5 high, 1 critical)
To address all issues, run:
npm audit fix
Run `npm audit` for details.
npm audit fix
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: undefined,
npm WARN EBADENGINE required: { node: '10' },
npm WARN EBADENGINE current: { node: 'v14.16.0', npm: '7.19.1' }
npm WARN EBADENGINE }
removed 2 packages, changed 27 packages, and audited 349 packages in 7s
11 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
Everything was working fine and suddenly the errors popped up.一切正常,突然出现错误。
I've solved it by updating my dependencies and also changing the node version in the package.json file.我已经通过更新我的依赖项并更改 package.json 文件中的节点版本来解决它。
I updated the node version to 14.16.0, but in the package.json file the node version was 10. So I've changed it to "node": "14"
and now everything is working fine.我将节点版本更新为 14.16.0,但在 package.json 文件中,节点版本为 10。所以我将其更改为"node": "14"
,现在一切正常。
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "eslint",
"serve": "firebase serve --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "14"
},
"dependencies": {
"@google-cloud/pubsub": "^2.17.0",
"axios": "^0.21.1",
"express": "^4.17.1",
"firebase-admin": "^11.0.0",
"firebase-functions": "^3.15.5",
"lodash": "^4.17.21"
},
"devDependencies": {
"eslint": "^5.12.0",
"eslint-plugin-promise": "^4.0.1",
"firebase-functions-test": "^0.1.7"
},
"private": true
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.