firebase-functions:
1.0.3
firebase-tools:
3.18.5
firebase-admin:
5.12.1
node
6.11.5 (seems to repro for all versions of node)
Deploy was successful. Emulation was not.
starter project should serve locally.
The first time I run, I get this.
asarazan ~/stencil/tmp/backend/functions $ firebase serve --only functions
=== Serving from '/Users/asarazan/stencil/tmp/backend'...
i functions: Preparing to emulate functions.
âš functions: Failed to load functions source code. Ensure that you have the latest SDK by running npm i --save firebase-functions inside the functions directory.
âš functions: Error from emulator. Error parsing triggers: Cannot find module '/Users/asarazan/stencil/tmp/backend/functions'
If I run a deploy, then try to serve locally, it hangs:
asarazan ~/stencil/tmp/backend/functions $ firebase serve --only functions
=== Serving from '/Users/asarazan/stencil/tmp/backend'...
i functions: Preparing to emulate functions.
This leads me to believe that there are two problems here:
Hi did you compile the code each time before you run "firebase serve"? For simplicity, you can run "npm run serve" inside the functions folder, which does both.
ah I was under the impression that it went the other way around-- I didn't see any documentation mentioning the need to compile, so I assumed it was a part of the firebase serve task
Glad you figured it out! Yes, we should fix the documentation, filed an internal bug for it.
Ran into this one today. ⨀_Ꙩ
Also encountered this today. Didn't see anything in the Getting Started documentation for Firebase + Typescript about this. It would be very helpful to mention this in the firebase serve command itself when Typescript files are detected.
Still broken ... 'npm run serve' works, is it possible to auto compile on updates?
@bbarthel I second this - need to use tsc --watch together with firebase serve
@gotexis are you also getting these lines after killing the server

It seems like the compilation restarts the function, but not very properly?
It tries to restart many many times and if I change code more it becomes more lines of 'your function was killed'
@vongohren sorry not getting that I think your problem is with the code itselg
@gotexis the code works fine, but it only happens when i stop the emulator. Maybe @laurenzlong can help out here
Hot reloading not working with typescript.
Each time for new changes I have to kill terminal and again run
npm run serve
And to support hot-reloading, I have to run
tsc -w
into another terminal.
Can't we run and stop both with a single command and why it's not supporting hot reloading ???
@vongohren
package.json
{
"name": "functions",
"scripts": {
"lint": "tslint --project tsconfig.json",
"build": "tsc",
"serve": "npm run build && firebase emulators:start --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "10"
},
"main": "lib/index.js",
"dependencies": {
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"firebase-admin": "^8.10.0",
"firebase-functions": "^3.6.1",
"nodemailer": "^6.4.10"
},
"devDependencies": {
"@types/cors": "^2.8.6",
"firebase-functions-test": "^0.2.0",
"tslint": "^5.12.0",
"typescript": "^3.8.0"
},
"private": true
}
tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "lib",
"sourceMap": true,
"strict": true,
"target": "es2017"
},
"compileOnSave": true,
"include": [
"src"
]
}
For feature requests / bugs for the emulation experience, please file issues in https://github.com/firebase/firebase-tools
@narendrasinghrathore not sure, but you can continue filing a bug in the repo lauren suggests, I just accepted this thing and move on :D :P Because it does not breake my code, it does not break my development, but it super annoying to see that many potential processes have been stacking up
Most helpful comment
Hi did you compile the code each time before you run "firebase serve"? For simplicity, you can run "npm run serve" inside the functions folder, which does both.