The Google Cloud Functions emulator is only supported on Node 6: https://github.com/GoogleCloudPlatform/cloud-functions-emulator

Note: The Emulator only supports Node v6.x.x. It does not support Node v8.x.x or Python."

But, Google Cloud Functions are deprecated for Node 6: https://cloud.google.com/functions/docs/concepts/nodejs-6-runtime

The Node.js 6 runtime has been deprecated. To ensure that your functions are on a supported version of Node.js, migrate them to Node.js 8 or Node.js 10. After 2020-04-22, function deployments that use Node.js 6 will be blocked. Cloud Functions that continue to use Node.js 6 after this time may be disabled."

How do I go about running functions (written for Node 8) locally?

1 Answers

1
Kolban On

Google has (April 2019) just released a new testing and development framework for Cloud Functions for Node.js based logic. The name of this framework is called Functions Framework for Node.js and is opened sourced on Github. If you visit the link just provided, you will find detailed documentation on how to download and use it. At the highest (and summary) level:

  1. npm install @google-cloud/functions-framework

  2. Write your code.

exports.helloWorld = (req, res) => {
  res.send('Hello, World');
};
  1. Run your code using npx @google-cloud/functions-framework --target=helloWorld

While these are the cheat sheet notes, I strongly recommend reading the whole README docs at the Github repository.