Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to load function definition from source: FirebaseError: User code failed to load. Cannot determine backend specification

[REQUIRED] Environment info

  • firebase-tools: 12.1.0
  • "firebase-admin": "^11.8.0",
  • "firebase-functions": "^4.3.1"
  • "firebase-functions-test": "^3.1.0"

**Platform: Windows wsl (Ubuntu)

  • Node: v18.16.0
  • Python: v3.10.6
  • openjdk: v"11.0.19"

i have followed the exact steps in

https://firebase.google.com/docs/functions/get-started?gen=2nd&hl=ko#about_this_tutorial

but it occurs

"Failed to load function definition from source: FirebaseError: User code failed to load. Cannot determine backend specification "

when i run "firebase emulators:start" command

[Error Report]

When I run 'firebase emulators:start'

`i emulators: Starting emulators: functions, firestore

⚠ functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth, database, hosting, pubsub, storage

i firestore: Firestore Emulator logging to firestore-debug.log

✔ firestore: Firestore Emulator UI websocket is running on 9150.

i ui: Emulator UI logging to ui-debug.log

i functions: Watching "/mnt/c/Users/sunwu/Downloads/Tryagain/pythontry/functions" for Cloud Functions...

✔ functions: Using node@18 from host.

⬢ functions: Failed to load function definition from source: FirebaseError: User code failed to load. Cannot determine backend specification

┌─────────────────────────────────────────────────────────────┐ │ ✔ All emulators ready! It is now safe to connect your app. │ │ i View Emulator UI at http://127.0.0.1:4000/ │ └─────────────────────────────────────────────────────────────┘

┌───────────┬────────────────┬─────────────────────────────────┐ │ Emulator │ Host:Port │ View in Emulator UI │ ├───────────┼────────────────┼─────────────────────────────────┤ │ Functions │ 127.0.0.1:5001 │ http://127.0.0.1:4000/functions │ ├───────────┼────────────────┼─────────────────────────────────┤ │ Firestore │ 127.0.0.1:8080 │ http://127.0.0.1:4000/firestore │ └───────────┴────────────────┴─────────────────────────────────┘

Emulator Hub running at 127.0.0.1:4400

Other reserved ports: 4500, 9150

in --debug

[2023-05-24T00:10:58.203Z] Building nodejs source

[2023-05-24T00:10:58.204Z] Failed to find version of module node: reached end of search path

/mnt/c/Users/sunwu/Downloads/Tryagain/pythontry/functions/node_modules

✔ functions: Using node@18 from host.

[2023-05-24T00:10:58.215Z] Could not find functions.yaml. Must use http discovery

[2023-05-24T00:10:58.240Z] Found firebase-functions binary at

'/mnt/c/Users/sunwu/Downloads/Tryagain/pythontry/functions/node_modules/.bin/firebase-functions'

[2023-05-24T00:11:02.712Z] Serving at port 8528

[2023-05-24T00:11:16.857Z] shutdown requested via /__/quitquitquit

⬢ functions: Failed to load function definition from source: FirebaseError: User code failed to load. Cannot determine backend specification {"metadata":{"emulator":{"name":"functions"},"message":"Failed to load function definition from source: FirebaseError: User code failed to load. Cannot determine backend specification"}}

it is just a simple project so i have no idea why its not working..

like image 625
sunwu Avatar asked Oct 27 '25 00:10

sunwu


2 Answers

Got the same error

Error: User code failed to load. Cannot determine backend specification.

Turns out that when I initialized a new project using firebase init the default nodejs version it uses is 18.

Just needed to change my version in package.json file to the current installed on my system. For me it was 16.

"engines": { "node": "16" },

Error Image

Error Image

Success Image

Success Image

like image 160
Syed Hamza Hoda Avatar answered Oct 29 '25 13:10

Syed Hamza Hoda


This error will happen if you upgrade firebase-functions, without upgrading your tooling.

In order to fix it, just run npm i -g firebase-tools

like image 32
Broda Noel Avatar answered Oct 29 '25 13:10

Broda Noel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!