Install npm for Google Cloud Functions
Use NPM to manage versions of Node.js on macOS
Install Cloud Client Libraries for Node.Js
In order to use Cloud Functions on your google SDK you need a specified version of Node.js. But assuming you already have a version of Node.js installed, you might want to keep the latest version of Node.js on your system for other purposes. Here is how to keep both.
1. Clear npm cache
Open spotlight using
Use the shortcut ⌘ + space and type in terminal, or
Navigate your applications folder > utilities
Navigate your applications folder > utilities
Run the following command in the terminal window:
npm cache clean -f
npm cache clean -f
The version of the package manager installed is shown in red.
You are provided with a command to update NPM.
2. Install NPM (nodes version manager)
Run the command shown in the terminal:
npm install -g
npm install -g
You now have npm installed!
3. Install the desired version of Node.js
Currently Cloud Functions is compatible with the following runtimes of Node.js: 10, 12 (beta)
Install version 12 beta of Node.Js. by running the command shown in the terminal:
npm install n 12
or
npm install 12 beta
And then run the following command to confirm the installation:
If you added beta you should see the additional packages installed:
+ n@6.7.0
+ 12@1.0.2
+ beta@0.0.1
4. Install Cloud Client Libraries for Node.js
Cloud client libraries are necessary to work with use Cloud Datastore, Firestore and BigQuery (these are available with the free tier of google cloud services)
Install the client library for the following by running the respective commands:
| For the full list of client libraries visit here: https://github.com/googleapis/google-cloud-node |
npm i @google-cloud/datastore
npm i @google-cloud/firestore
npm i @google-cloud/bigquery



Comments