Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upgrade node js version on google cloud build

So I recently upgraded my app from Angular 7 to Angular 8 and I'm having issues with the node version of the cloud build VM as Angular 8 requires node version 10.9 or greater as shown below:

error

How can I upgrade the node version of the Google cloud VM so I won't get this error again?

Thanks.

like image 920
Jack_b_321 Avatar asked May 29 '19 11:05

Jack_b_321


People also ask

How do I upgrade to Nodejs 12?

Just go to nodejs.org and use the latest installer. just downloaded newest version, install, went to command prompt typed node -v , saw change instantly.

Does Google Cloud support Nodejs?

Google Cloud lets you choose the best environment to run your Node. js applications, with options for serverless, Kubernetes, VMs, or custom hardware.


2 Answers

Ok, so after hours of Googling around it turns out Google cloud platform offers a registry of different npm cloud builders for use with Google cloud build.

I could have solved my issue by creating my own docker image but I wanted to avoid this in favour of the default cloud builders docker image. I changed my cloudbuild.yaml file to include the following builder 'gcr.io/cloud-builders/npm:node-10.10.0' instead of 'gcr.io/cloud-builders/npm' this then updated the node version to node 10.10.0 and just like magic Angular 8 can now be built by google cloud build!

Specific node versions from the cloud builders repository can be found here: https://console.cloud.google.com/gcr/images/cloud-builders/GLOBAL/npm

cloudbuild.yaml file

like image 62
Jack_b_321 Avatar answered Sep 18 '22 23:09

Jack_b_321


As suggested by their documentation you should instead using an official node image and specifying the npm entrypoint:

steps:
- name: node:10.15.1
  entrypoint: npm
  args: ['install']

https://github.com/GoogleCloudPlatform/cloud-builders/blob/master/npm/README.md

like image 43
39ro Avatar answered Sep 20 '22 23:09

39ro