NPM install from Google Cloud Repository in GCP App Engine

1.1k Views Asked by At

I'm trying to deploy a node.js program in Google Cloud's App Engine, but am being given the following error:

Step #1: npm ERR! Error while executing:
Step #1: npm ERR! /usr/bin/git ls-remote -h -t https://source.developers.google.com/p/(project)/r/(repository)
Step #1: npm ERR! 
Step #1: npm ERR! fatal: remote error: 
Step #1: npm ERR! 
Step #1: npm ERR! 
Step #1: npm ERR! Invalid authentication credentials.
Step #1: npm ERR! 
Step #1: npm ERR! Please generate a new identifier:
Step #1: npm ERR!   https://source.developers.google.com/auth/start?scopes=https://www.googleapis.com/auth/cloud-platform
Step #1: npm ERR! 
Step #1: npm ERR! 
Step #1: npm ERR! 
Step #1: npm ERR! exited with error code: 128

This is because of a dependency in my project located at https://source.developers.google.com/p/(project)/r/(repository). I am able to install this dependency without errors both on my local machine and in the cloud shell with the help of a .netrc file, as described by the page given in the error message, but it seems that I am unable to copy this file in my deployment.

Is there a way to specify what credentials should be used? Note that I am unable to use the user:pass@host format explained in the npm docs because the username and password Google give me contain @s and \s.

1

There are 1 best solutions below

0
On

I managed to get this working using the following recipe:

  1. The source url has to start with git+https://, not just https:// (thanks Lugassy), don't use username or password
  2. Fetch a piece of google magic from Google's Git configurator
  3. Run the command from Google in terminal