10

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.

4 Answers 4

14

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 that will be found in 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
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you! I was installing the dependencies in the main project folder instead of in the functions folder. I noticed that the package.json didn't include the blurhash dependency and added it manually. Obv that didn't work out. I recreated the project from scratch and installed the dependencies in the functions folder and it deployed successfully.
running build with --debug showed this as well. [update-europe-west2-api] Retrying task index 0 I ultimately had to delete the lock file, delete all modules/ and lib/ cachce folders and finally, the project build and deployed. The red herring was i'd narrowed the build failure down to how long a specific file name was. i.e. A.ts would build. AA.ts would fail.
Thank you! Deleting package-lock.json and re-deploying did the trick
3

My problem was that i did not select the right region when calling functions. Set the region on which you have your project on. In my case:

export const myfunc = functions.region('europe-west1').https...

More info: https://firebase.google.com/docs/functions/locations

Comments

2

for others trying to upload cloudfunction with receiving an error. This may solve your error:

Make sure that the node version you are running is equal to the node version you specified in your package.json file.

search for those two sections in your firebase-debug.log

[debug] [2022-02-02T15:57:12.601Z] Node Version:  v16.13.0

and

[debug] [2022-02-02T15:57:17.055Z] > [functions] package.json contents: {
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    ...
  },
  "engines": {
    "node": "14"
  },

and then go to your firebase/functions/package.json and change the version for the engines/node property

Comments

0

By removing the package-lock.json and node_modules folder and then running npm install has resolved the issue for me.

enter image description here

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.