Google Cloud Functions local testing – auto releod

Cloud Functions is Google Cloud’s event-driven serverless compute platform. Run your code locally or in the cloud without having to provision servers. Go from code to deploy with continuous delivery and monitoring tools. Cloud Functions scales up or down, so you pay only for compute resources you use. Easily create end-to-end complex development scenarios by connecting with existing Google Cloud or third-party services.

It’s easy enough to get up and running with a local dev environment but with the basic setup you need to restart the dev server on every file change. Doing a lot of Google AppEngine development recently I got use to the dev server reloading changed files. When you have the basic environment up and running (specified here: just follow these simple steps.

npm -g install npm-watch

Then open the basic package.json file and add the highlights below:

  "name": "reloadTest",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "author": "Kristofer Källsbo",
  "license": "ISC",
  "dependencies": {
    "@google-cloud/functions-framework": "^1.4.0"
  "watch": {
    "start": "*.js"
  "scripts": {
    "watch": "npm-watch start",
    "start": "functions-framework --target=reloadTest"

Now run your dev environment with

npm run watch

And whenever you update a file in your project npm will reload the dev environment.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: