I'm trying to create a Firebase Function but I'm running into a deploy error, even when deploying the default helloworld
function.
The firebase-debug.log file mentions this:
Could not find image for function projects/picci-e030e/locations/us-central1/functions/helloWorld.
I have been trying to debug and so far have not been able to solve it...
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
}
My version of node:
v14.16.0
Appreciate your help.
CodePudding user response:
Could not find image for function projects/picci-e030e/locations/us-central1/functions/helloWorld.
The Firebase Function deployment failed because it cannot find the image built based on your function app. There might be a problem building in your app, it could be your dependencies or files.
I replicated your issue, received the same error and solved it. There's a problem with the package.json
file and package-lock.json
. If you just add(without installing) your dependency in package.json
you should delete or remove your package-lock.json
will be found function directory before you deploy it again using the deployment command:
firebase deploy --only functions
or you can just install your dependency to make sure it will be added to your package.json
and package-lock.json
file, deploy again. For example:
npm install --save blurhash