npmpackage.jsonnpm-publish

Could not resolve hostname github.com: Name or service not known


Started receiving the error; Could not resolve hostname github.com: Name or service not known after updating our npm version from 6.14.14 to 8.1.2 when trying to run npm publish against our private package to our private registry.

Our package.json is configured with "private": true and we have also configured our private registry in a local .npmrc file on the build server.

> npm publish dist/{{project}}
npm ERR! code 128
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects ls-remote ssh://git@github.com/dist/{{project}}.git
npm ERR! ssh: Could not resolve hostname github.com: Name or service not known
npm ERR! fatal: Could not read from remote repository.
npm ERR! 
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.

Why is this updated version of npm trying to publish to github.com?

Switching the build agent target back to the 6.14.14 install does not try to publish out to github.com and successfully publishes it to our private registry.


Solution

  • I just had that issue after migrating to Node 16 & npm 8 :

    Per this issue, the publish path needs a trailing slash.

    So npm publish dist/myProject should be npm publish dist/myProject/