Issue with git dependency on node version upgrade

Viewed 354

I am running a VUE.JS app in a Docker container. The app is currently using node 14.19.0, but I tried upgrading the version to node 15/16. After changing the node version in the Dockerfile and updating some of the devDependencies, I get an NPM error:


npm ERR! npm ERR! An unknown git error occurred

npm ERR! npm ERR! command git --no-replace-objects ls-remote ssh://git@github.com/[NAMESPACE_PLACEHOLDER]/[REPO_PLACEHOLDER].git

npm ERR! npm ERR! Warning: Permanently added 'github.com' (ECDSA) to the list of known hosts.

npm ERR! npm ERR! git@github.com: Permission denied (publickey).

npm ERR! npm ERR! fatal: Could not read from remote repository.

npm ERR! npm ERR! 

npm ERR! npm ERR! Please make sure you have the correct access rights

npm ERR! npm ERR! and the repository exists.

In my package.json file, the repo is loaded with https, not ssh:

"package-name-placeholder": "https://github.com/[NAMESPACE_PLACEHOLDER]/[REPO_PLACEHOLDER].git#v0.1.15"

This exact method is working with Node 14.19.0. I read that there might be an issue with trailing slashes. I tried using them, but the error persists.

Have anyone managed to do something about a similar issue?

Thanks.

1 Answers

Try in your Dockerfile a:

RUN git config --global url."https://${GIT_ACCESS_TOKEN}@github.com".insteadOf "ssh://git@github.com"

(If those repositories are public, you do not need the ${GIT_ACCESS_TOKEN}@ part: it would be an ARG GIT_ACCESS_TOKEN passed with a docker build --build-arg GIT_ACCESS_TOKEN=xxx)

You can see here this was reported before:

npm version change in alpine-16's image, and I'm pretty sure that this problem is related to npm version.

Related