The Node.js Emulator is a Node.js application that implements the Cloud Functions REST and gRPC APIs, and includes a command line interface for managing the application. The Node.js Emulator allows you to deploy, run, and debug Node.js Cloud Functions on your local machine before deploying them to the production Cloud Functions service.
The Node.js Emulator is an Open Source project, hosted on GitHub.
Getting started
The Node.js Emulator is distributed as a standard npm package, so
you can install it with a standard npm install command:
npm install -g @google-cloud/functions-emulator
Or you can use Yarn if you prefer:
yarn global add @google-cloud/functions-emulator
Using the Node.js Emulator
After installation you should have a global functions command available. To
verify this, type the following command in a terminal window:
functions --help
If your terminal already has a conflicting functions command, the
Node.js Emulator's command line interface can also be accessed using the
functions-emulator command.
You can get help on any command by running the following:
functions COMMAND --help
Provide a Project ID as shown below before starting the Node.js Emulator:
functions config set projectId YOUR_PROJECT_ID
Starting and stopping the Node.js Emulator
Before you can deploy a function, you need to start the Node.js Emulator:
functions start
You stop the Node.js Emulator by calling stop:
functions stop
If the Node.js Emulator fails to stop for any reason, you can use the kill
command to forcibly terminate the underlying process:
functions kill
Deploying functions to the Node.js Emulator
Deploying functions to the Node.js Emulator uses the same syntax as the
gcloud command-line tool.
To deploy an HTTP function to the Node.js Emulator:
functions deploy helloWorld --trigger-http
This deploys the function found in the current working directory. To deploy from
a different location, use the --local-path flag:
functions deploy helloWorld --trigger-http --local-path=~/myFunction
Calling functions in the Node.js Emulator
To invoke a function deployed to the Node.js Emulator, use the call
command:
functions call helloWorld
To send a payload to the function, use the --data flag:
functions call helloWorld --data='{"message":"Hello World"}'
You can also invoke functions deployed with an HTTP trigger by sending a request to the URL provided after deployment.
Viewing logs
Logs emitted from your function are written to the local file system. You can
view them via the logs command:
functions logs read
You can also view the log file itself on the local file system, and can
determine its location by issuing a status command:
functions status
Debugging with the Node.js Emulator
You can debug your functions running in the Node.js Emulator using either the standard Node.js Debugger or the V8 Inspector integration. To debug using the standard Node.js Debugger, run the following command:
functions debug helloWorld
To debug using the V8 Inspector integration, run the following command:
functions inspect helloWorld
You can also configure the Debugger's port or force the function to pause execution until you attach to the Debugger. Run either of the following commands for details:
functions debug --help
or
functions inspect --help
After a deployed function has entered debug mode, you can attach any standard Node.js debugging client to its debugger.
To take your function out of debug mode, run the following:
functions reset helloWorld
or to restart the function and keep its debugging settings, run the following:
functions reset helloWorld --keep
Run functions reset --help for details.
You can find more detailed documentation on how to debug with the Node.js Emulator with Chrome Devtools, Visual Studio Code, or Webstorm on the GitHub page.
Getting help
To view detailed Node.js Emulator help, add the --help flag to any command:
functions --help
or
functions COMMAND --help
More detailed documentation is also available on GitHub, where you can also view and/or file any issues.


