'package-lock.json has links like git://github.com/danteata/passport-oauth.git

I am using AWS Amplify, when I push code of react to my branch, CI/CD runs and on "npm install" build fails on AWS Amplify, with error

npm 2022-01-11T09:31:06.876Z [WARNING]: ERR! Error while executing: npm ERR! /usr/bin/git ls-remote -h -t git://github.com/danteata/passport-oauth.git npm ERR! npm ERR! fatal: remote error: npm ERR! The unauthenticated git protocol on port 9418 is no longer supported. npm ERR! Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information. npm ERR! npm ERR! exited with error code: 128

I've also tried to replce git://git.. with https://git.... in package-lock.json (suggested by https://github.blog/2021-09-01-improving-git-protocol-security-github/) but the build fails with the same error.



Solution 1:[1]

We got over this by adding git config --global url."https://".insteadOf git:// to the Build Specification amplify.yml preBuild commmands (just before npm install).

See below:

amplify.yml

...
frontend:
  phases:
    preBuild:
      commands:
        - git config --global url."https://".insteadOf git://
        - npm install
...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 B Gam