NPM install fails when a git+ssh project is linked

What I Wanted to Do

run “npm i” after linking a dependency that is in a git repository with ssh access

What Happened Instead

I git the error “npm ERR! Cannot read property ‘0’ of undefined”

Reproduction Steps

run "mkdir main-project && cd main-project && npm init -y"

edit the package.json (main-project) and add:

"dependencies": {
    "git-project": "git+ssh://foo@foo.com/foo.git"
  }

run  "npm link git-project"
run "npm i"

Using this fake git url i got this error:

The authenticity of host 'foo.com (23.23.86.44)' can't be established.lTree
ECDSA key fingerprint is SHA256:3NEgxkfS6DMkV/AsX32aXbe619Jg/Cj8yI23aH2/t+c

That it would be ok if the project wasn’t linked but I think npm should not call the server at all in this case.

If I replace the the git url for a valid one i got this error:

npm ERR! Cannot read property ‘0’ of undefined

Details

I have debugged a bit the npm code and I think npm is looking for a “_from” property that is not present in the package.json of git-project.

logs:

0 info it worked if it ends with ok
1 verbose cli [ ‘/home/jesus/.nvm/versions/node/v8.11.1/bin/node’,
1 verbose cli ‘/home/jesus/.nvm/versions/node/v8.11.1/bin/npm’,
1 verbose cli ‘i’ ]
2 info using npm@6.11.3
3 info using node@v8.11.1
4 verbose npm-session fb8a481eb3e4f5f4
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall main-project@1.0.0
7 info lifecycle main-project@1.0.0~preinstall: main-project@1.0.0
8 silly install loadCurrentTree
9 silly install readLocalPackageData
10 verbose stack TypeError: Cannot read property ‘0’ of undefined
10 verbose stack at npa (/home/jesus/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:34:25)
10 verbose stack at doesChildVersionMatch (/home/jesus/.nvm/versions/node/v8.11.1/lib/node_modules/npm/lib/install/deps.js:61:22)
10 verbose stack at versionMatch (/home/jesus/.nvm/versions/node/v8.11.1/lib/node_modules/npm/lib/install/deps.js:753:12)
10 verbose stack at Array.filter ()
10 verbose stack at exports.findRequirement (/home/jesus/.nvm/versions/node/v8.11.1/lib/node_modules/npm/lib/install/deps.js:763:23)
10 verbose stack at findChild (/home/jesus/.nvm/versions/node/v8.11.1/lib/node_modules/npm/lib/install/deps.js:122:17)
10 verbose stack at computeMetadata (/home/jesus/.nvm/versions/node/v8.11.1/lib/node_modules/npm/lib/install/deps.js:132:9)
10 verbose stack at Installer.normalizeCurrentTree (/home/jesus/.nvm/versions/node/v8.11.1/lib/node_modules/npm/lib/install.js:408:3)
10 verbose stack at Array. (/home/jesus/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
10 verbose stack at LOOP (/home/jesus/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:14)
10 verbose stack at /home/jesus/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/slide/lib/chain.js:18:7
10 verbose stack at iferr (/home/jesus/.nvm/versions/node/v8.11.1/lib/node_modules/npm/lib/install.js:362:5)
10 verbose stack at a (/home/jesus/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/iferr/iferr.js:3:64)
10 verbose stack at asyncMap (/home/jesus/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/slide/lib/async-map.js:27:18)
10 verbose stack at exports.getAllMetadata (/home/jesus/.nvm/versions/node/v8.11.1/lib/node_modules/npm/lib/install/deps.js:219:3)
10 verbose stack at Installer.loadArgMetadata (/home/jesus/.nvm/versions/node/v8.11.1/lib/node_modules/npm/lib/install.js:360:3)
11 verbose cwd /home/jesus/dev/test/npm/main-project
12 verbose Linux 4.18.0-25-generic
13 verbose argv “/home/jesus/.nvm/versions/node/v8.11.1/bin/node” “/home/jesus/.nvm/versions/node/v8.11.1/bin/npm” “i”
14 verbose node v8.11.1
15 verbose npm v6.11.3
16 error Cannot read property ‘0’ of undefined
17 verbose exit [ 1, true ]

Platform Info

$ npm --versions
{ 'main-project': '1.0.0',
  npm: '6.11.3',
  ares: '1.10.1-DEV',
  cldr: '32.0',
  http_parser: '2.8.0',
  icu: '60.1',
  modules: '57',
  nghttp2: '1.25.0',
  node: '8.11.1',
  openssl: '1.0.2o',
  tz: '2017c',
  unicode: '10.0',
  uv: '1.19.1',
  v8: '6.2.414.50',
  zlib: '1.2.11' }

$ node -p process.platform
linux