Why is my Firebase Functions emulator not running my changes in Typescript?
Asked Answered
G

2

8

I am using the Firebase Functions emulator. But when I make a change to the code, it still runs the old version. I am using Typescript.

How can I get it to run the new version?

Gammon answered 9/10, 2020 at 17:14 Comment(4)
You have to configure your app to use the emulator, then do something in it to trigger the function, the same as if it was deployed. This is all covered in the documentation. Without seeing your functions and understanding what they're supposed to do, Stack Overflow will not be much help.Ahoy
@DougStevenson I did configure my app to use the emulator, and it is successfully running locally. It is just running the wrong version of the code.Gammon
You're going to have to edit the question to explain what you did and be clear about what's not working the way you expect.Ahoy
@DougStevenson Thank you. I found out of the problem, and rephrased my question to be more useful to others in the future.Gammon
G
7

As stated in their documentation:

Note: Code changes you make during an active session are automatically reloaded by the emulator. If your code needs to be transpiled (TypeScript, React) make sure to do so before running the emulator.

You can do this by running npm run build in your functions folder.

Gammon answered 9/10, 2020 at 18:19 Comment(0)
C
7

npm run build -- --watch | firebase emulators:start --only functions

Crinite answered 24/1, 2024 at 2:33 Comment(2)
You could also add this to your main package.json in the root dir. "emulators": "npm run build --prefix functions -- --watch | firebase emulators:start", which also handles TS.Protuberant
This should be standard in their templateLoris

© 2022 - 2025 — McMap. All rights reserved.