1

If we deploy a node.js 12 project to App Engine (standard environment) and it has a dependency in package.json that looks like this:

"some-lib": "git+https://github.com/a/b.git",

Then this will lead to a deployment error when we execute gcloud app deploy. This is from the App Engine logs:

Step #6 - "builder": npm ERR! Error while executing:
Step #6 - "builder": npm ERR! /usr/bin/git ls-remote -h -t ssh://git@github.com/a/b.git
Step #6 - "builder": npm ERR! 
Step #6 - "builder": npm ERR! Host key verification failed.
Step #6 - "builder": npm ERR! fatal: Could not read from remote repository.

So even though the dependency is provided as a HTTPS URL, it will try to fetch it with SSH and this doesn't seem to work on App Engine.

It works if I go to package-lock.json and manually change the version string to start with https, but that's not really a viable solution, because it will be overwritten again.

Any ideas how it can be accomplished to provide a dependency with a GitHub URL (SSH or HTTPS) to App Engine?

Klemens Zleptnig
  • 1,698
  • 20
  • 36

2 Answers2

1

Check first your git configuration in the deployment environment (Google App Engine, in your Google Cloud Console), assuming Git 2.26 or more:

git config --global --show-origin --show-scope-l
git config --system --show-origin --show-scope -l
# if you are in a local repository:
git config --local --show-origin --show-scope -l

Look for any configuration like url."ssh://git@github.com".insteadOf "git+https://github.com"

Such a rule would rewrite the URL, explaining why your initial dependency shows up as an SSH URL.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • You mean on the local machine (from which I run `gcloud app deploy`)? Mhm I tried the commands but they don't work - I have version 2.20.1. `error: unknown option 'show-scope'`. But even without that they just show the help. Shouldn't I add `-l` to list the configurations? – Klemens Zleptnig Mar 18 '21 at 22:36
  • BTW I don't get the error on my local development machine, I get it only in the App Engine logs. – Klemens Zleptnig Mar 18 '21 at 22:39
  • @KlemensZleptnig Yes, I forgot the -l. And you can safely update Git (https://stackoverflow.com/a/41357503/6309). 2.20 is indeed a bit old for that option. – VonC Mar 18 '21 at 23:44
  • On my GC appengine use node v.16.1 and git 2.30, but still have problem with npm install (one of modules in my `packages.json` use git+https in their `package.json`), I don't have any global gitconfig – CodeBy Apr 27 '22 at 16:09
1

As we can see in this issue the problem relies in NPM that caused to convert any git+https reference into git+ssh.

From what I understood, the issue has been patched but is not available on NPM 6, that is the version used in the nodejs12 and nodejs14 enviroment of GAE.

What I suggest is to use nodejs16 as runtime of your App Engine application

  • Ah... I didn't know that nodejs16 is already available as a runtime at GAE - seems to be pretty new? https://cloud.google.com/appengine/docs/standard/nodejs/runtime – Klemens Zleptnig Jan 19 '22 at 22:04
  • I have node v.16.1, but still got same error How to solve it? – CodeBy Apr 27 '22 at 16:01