unable to deploy changes to firebase cloud
Action: "Firebase Deploy" in cmd
results:
i deploying functions
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i functions: ensuring required API cloudbuild.googleapis.com is enabled...
+ functions: required API cloudfunctions.googleapis.com is enabled
+ functions: required API cloudbuild.googleapis.com is enabled
i functions: preparing codebase default for deployment
Error: Failed to load function definition from source: Failed to generate manifest from function source: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in C:\Users\rushikesh.chaskar\IdeaProjects\todosmanager\node_modules\firebase\package.json
I soved it by upgrading the firebase-functions dependency
yarn add firebase-functions
In the functions directory
In my case, the problem was a TypeScript enum
which I turned into an array to use in my code. Apparently, firebase-functions
doesn't like that.
I ended up defining the array directly in my code without using the enum
from my type definitions.
In my case, I forgot to include the subfolder path in the configuration file.
Code(index.ts):
exports.my_group = require('./subfolder/parser')
Error:
Error: Failed to load function definition from source: Failed to generate manifest from function source: Error: Cannot find module './subfolder/parser'
Solution was to change
"include": [
"src"
]
to
"include": [
"src", "src/**/*"
]
in tsconfig.json file.
In my case I had an error in my code that only surfaced when deploying.
The error I got was firebase functions "Failed to generate manifest from function source: TypeError: Cannot read properties of undefined (reading 'toString')"
After about an hour of commenting out everything and then uncommenting a chunk at a time I realized my code wasn't deploying to firebase functions because of a line I wrote that included process.env.FUNCTIONS_EMULATOR.toString()
. Apparently when deploying process.env.FUNCTIONS_EMULATOR
is null so trying to call toString
on it throws an error.
I changed that line to `${process.env.FUNCTIONS_EMULATOR}`
and now my firebase functions deploy.
Adding to the never ending list of problems. If you get something like the below error, check your imports.
Failed to load function definition from source: FirebaseError: Failed to load function definition from source: Failed to generate manifest from function source: TypeError: Cannot read properties of undefined (reading 'INTERNAL')
I noticed some outdated Admin SDK instructions had the following:
import {initializeApp} from "firebase-admin";
Where as the correct import is:
import {initializeApp} from "firebase-admin/app";
My issue was related to Firebase functions config was set as null when doing a firebase serve locally.
I got the following error:
Error: Failed to load function definition from source: Failed to generate manifest from function source: ReferenceError: cannot read key from undefined
Make sure you have a .runtimeconfig.json file inside your functions folder , in case you don't have it, to save that file from your current configuration run this command from the terminal (again inside the functions folder):
firebase functions:config:get > .runtimeconfig.json
check this github issue
Personally, I was using jest
to test my modules. I had files looking like this:
potatoes.js
potatoes.test.js
So importing doesn't work when I deploy
import {potato} from "./potatoes"
I had to do it like this
import {potato} from "./potatoes.js"
To resolve this issue I upgrade firebase functions by using npm install --save firebase-functions@latest in my functions directory
I had been using an outdated version of firebase-functions.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.