"firebase serve" in firebase functions is not running the latest changes

firebase serve doesn't seem to be running npm build. But if you look inside functions/package.json, you can see there is already a serve script there that performs npm run build && firebase serve --only functions. So if you just do:

cd functions
npm run serve

You can build and serve without having to do two separate commands.


I don't think you can just switch between Javascript and Typescript in an initialized project. The setup for Typescript is a bit different than Javascript. You will need to migrate your Javascript project to Typescript.

To migrate your project from JS to TS follow this firebase-functions documentation on :

Migrating an existing JavaScript Cloud Functions project

Typescript project setup:

Typescript project setup


If you want to reload the changes to your TypeScript when running firebase serve or firebase functions:shell, all you have to do is build your project again using npm script that was created for you when you initialized the project (see package.json):

cd functions
npm run build

This will transpile your TypeScript to JavaScript, and the changes to the JavaScript will get picked up by the emulator automatically.

Also, if you are a more advanced TypeScript user, you can run tsc --watch to automatically compile TS to JS when source files change on disk. You can read more about that in this blog.


If you are looking for hot reloading i just did it like below:

"start:emulators": "firebase emulators:start --only functions",
"ts:watch": "tsc --watch",
"dev": "concurrently --kill-others \"npm run start:emulators\" \"npm run ts:watch\"",

It will run both firebase and ts watch in parallel, which will help your development speed