Firebase 功能部署失败
Firebase function failing to deploy
我正在尝试创建一个 Firebase 函数,但我 运行 遇到部署错误,即使在部署默认 helloworld
函数时也是如此。
firebase-debug.log 文件提到了这一点:
Could not find image for function projects/picci-e030e/locations/us-central1/functions/helloWorld.
我一直在调试,至今没能解决...
firebase-debug.log
[info] Functions deploy had errors with the following functions:
helloWorld(us-central1)
[debug] [2021-11-18T21:54:08.946Z] Missing URI for HTTPS function in printTriggerUrls. This shouldn't happen
[info] i functions: cleaning up build files...
[debug] [2021-11-18T21:54:08.948Z] >>> [apiv2][query] GET https://us.gcr.io/v2/picci-e030e/gcf/us-central1/tags/list [none]
[debug] [2021-11-18T21:54:09.407Z] <<< [apiv2][status] GET https://us.gcr.io/v2/picci-e030e/gcf/us-central1/tags/list 200
[debug] [2021-11-18T21:54:09.407Z] <<< [apiv2][body] GET https://us.gcr.io/v2/picci-e030e/gcf/us-central1/tags/list {"child":[],"manifest":{},"name":"picci-e030e/gcf/us-central1","tags":[]}
[debug] [2021-11-18T21:54:09.407Z] Could not find image for function projects/picci-e030e/locations/us-central1/functions/helloWorld
[debug] [2021-11-18T21:54:09.481Z] Error: Failed to create function helloWorld in region us-central1
at /usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/release/fabricator.js:38:11
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Fabricator.createV1Function (/usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/release/fabricator.js:161:32)
at async Fabricator.createEndpoint (/usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/release/fabricator.js:116:13)
at async handle (/usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/release/fabricator.js:75:17)
[error]
[error] Error: There was an error deploying functions
index.js:
const functions = require("firebase-functions");
// Create and Deploy Your First Cloud Functions
// https://firebase.google.com/docs/functions/write-firebase-functions
exports.helloWorld = functions.https.onRequest((request, response) => {
functions.logger.info("Hello logs!", {structuredData: true});
response.send("Hello from Firebase!");
});
// const getBlurhash = require("./get_blurhash");
// exports.getBlurhash = getBlurhash.generateHash;
Package.json:
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "eslint",
"serve": "firebase emulators:start --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "14"
},
"main": "index.js",
"dependencies": {
"firebase-admin": "^9.8.0",
"firebase-functions": "^3.14.1",
"blurhash": "^1.1.4"
},
"devDependencies": {
"eslint": "^7.6.0",
"eslint-config-google": "^0.14.0",
"firebase-functions-test": "^0.2.0"
},
"private": true
}
我的节点版本:
v14.16.0
感谢您的帮助。
Could not find image for function projects/picci-e030e/locations/us-central1/functions/helloWorld.
Firebase Function 部署失败,因为找不到基于您的函数应用构建的图像。您的应用程序构建可能存在问题,可能是您的依赖项或文件。
我复制了你的问题,收到了同样的错误并解决了。 package.json
文件和 package-lock.json
有问题。如果您只是添加(而不安装)您在 package.json
中的依赖项,您应该删除或删除 您的 package-lock.json
在使用部署命令再次部署之前在功能目录中找到:
firebase deploy --only functions
或者您可以 安装 您的依赖项以确保它会被添加到您的 package.json
和 package-lock.json
文件中,再次部署。例如:
npm install --save blurhash
其他人在尝试上传 cloudfunction 时遇到错误。
这可能会解决您的错误:
确保您 运行 的节点版本等于您在 package.json 文件中指定的节点版本。
在您的 firebase-debug.log
中搜索这两个部分
[debug] [2022-02-02T15:57:12.601Z] Node Version: v16.13.0
和
[debug] [2022-02-02T15:57:17.055Z] > [functions] package.json contents: {
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
...
},
"engines": {
"node": "14"
},
然后转到 firebase/functions/package.json
并更改 engines/node 属性
的版本
我的问题是我在调用函数时没有 select 正确的区域。设置您的项目所在的区域。就我而言:
export const myfunc = functions.region('europe-west1').https...
我正在尝试创建一个 Firebase 函数,但我 运行 遇到部署错误,即使在部署默认 helloworld
函数时也是如此。
firebase-debug.log 文件提到了这一点:
Could not find image for function projects/picci-e030e/locations/us-central1/functions/helloWorld.
我一直在调试,至今没能解决...
firebase-debug.log
[info] Functions deploy had errors with the following functions:
helloWorld(us-central1)
[debug] [2021-11-18T21:54:08.946Z] Missing URI for HTTPS function in printTriggerUrls. This shouldn't happen
[info] i functions: cleaning up build files...
[debug] [2021-11-18T21:54:08.948Z] >>> [apiv2][query] GET https://us.gcr.io/v2/picci-e030e/gcf/us-central1/tags/list [none]
[debug] [2021-11-18T21:54:09.407Z] <<< [apiv2][status] GET https://us.gcr.io/v2/picci-e030e/gcf/us-central1/tags/list 200
[debug] [2021-11-18T21:54:09.407Z] <<< [apiv2][body] GET https://us.gcr.io/v2/picci-e030e/gcf/us-central1/tags/list {"child":[],"manifest":{},"name":"picci-e030e/gcf/us-central1","tags":[]}
[debug] [2021-11-18T21:54:09.407Z] Could not find image for function projects/picci-e030e/locations/us-central1/functions/helloWorld
[debug] [2021-11-18T21:54:09.481Z] Error: Failed to create function helloWorld in region us-central1
at /usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/release/fabricator.js:38:11
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Fabricator.createV1Function (/usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/release/fabricator.js:161:32)
at async Fabricator.createEndpoint (/usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/release/fabricator.js:116:13)
at async handle (/usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/release/fabricator.js:75:17)
[error]
[error] Error: There was an error deploying functions
index.js:
const functions = require("firebase-functions");
// Create and Deploy Your First Cloud Functions
// https://firebase.google.com/docs/functions/write-firebase-functions
exports.helloWorld = functions.https.onRequest((request, response) => {
functions.logger.info("Hello logs!", {structuredData: true});
response.send("Hello from Firebase!");
});
// const getBlurhash = require("./get_blurhash");
// exports.getBlurhash = getBlurhash.generateHash;
Package.json:
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "eslint",
"serve": "firebase emulators:start --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "14"
},
"main": "index.js",
"dependencies": {
"firebase-admin": "^9.8.0",
"firebase-functions": "^3.14.1",
"blurhash": "^1.1.4"
},
"devDependencies": {
"eslint": "^7.6.0",
"eslint-config-google": "^0.14.0",
"firebase-functions-test": "^0.2.0"
},
"private": true
}
我的节点版本:
v14.16.0
感谢您的帮助。
Could not find image for function projects/picci-e030e/locations/us-central1/functions/helloWorld.
Firebase Function 部署失败,因为找不到基于您的函数应用构建的图像。您的应用程序构建可能存在问题,可能是您的依赖项或文件。
我复制了你的问题,收到了同样的错误并解决了。 package.json
文件和 package-lock.json
有问题。如果您只是添加(而不安装)您在 package.json
中的依赖项,您应该删除或删除 您的 package-lock.json
在使用部署命令再次部署之前在功能目录中找到:
firebase deploy --only functions
或者您可以 安装 您的依赖项以确保它会被添加到您的 package.json
和 package-lock.json
文件中,再次部署。例如:
npm install --save blurhash
其他人在尝试上传 cloudfunction 时遇到错误。 这可能会解决您的错误:
确保您 运行 的节点版本等于您在 package.json 文件中指定的节点版本。
在您的 firebase-debug.log
中搜索这两个部分[debug] [2022-02-02T15:57:12.601Z] Node Version: v16.13.0
和
[debug] [2022-02-02T15:57:17.055Z] > [functions] package.json contents: {
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
...
},
"engines": {
"node": "14"
},
然后转到 firebase/functions/package.json
并更改 engines/node 属性
我的问题是我在调用函数时没有 select 正确的区域。设置您的项目所在的区域。就我而言:
export const myfunc = functions.region('europe-west1').https...