I haven't touched any firebase related files and I can't seem to figure out why exactly this has just started occuring, but I keep getting:
We were unable to load your functions code. (see above)
- It appears your code is written in Typescript, which must be compiled before emulation.
- You may be able to run "npm run build" in your functions directory to resolve this.
my firebase config file:
{
"functions": {
"predeploy": "npm --prefix \"$RESOURCE_DIR\" run build",
"source": "server"
}
}
and my folder structure:
My tsconfig:
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"sourceMap": true,
"outDir": "./dist"
},
"exclude": ["node_modules", "test", "**/*spec.ts"],
"include": ["src/**/*", "src"]
}
Found the issue in my tsconfig.json
Firebase will look in the package.json's main property to find your function code, in my case I had:
"main": "dist/index.js",
but index.js is outside the SRC folder and to get vscode to shut up about the tsconfig file I added that 'includes' property there that broke things.
Removing the includes/excludes from there works perfectly.
This mistake was easily identifiable from my screenshot and tsconfig that I had in my first post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With