"missing package name" error when installing from GitHub

cli

(Adam Spiers) #1

What I Wanted to Do

I wanted to add a dependency from my website to my GitHub fork of gatsby.js, and have that install locally.

What Happened Instead

I got a cryptic error:

npm ERR! Can't install git+ssh://git@github.com/aspiers/gatsby.git#a00aa4eed4c4d821544d33a85fe3caca36ad9bde: Missing package name

Reproduction Steps

Run:

npm i -S 'aspiers/gatsby#sort-chunks'

Details

This results in a rather cryptic Missing package name error:


npm ERR! A complete log of this run can be found in:
npm ERR!     /home/adam/.npm/_logs/2019-01-06T17_59_47_916Z-debug.log

I have no clue what that is supposed to mean. The debug.log has:

1 verbose cli [ '/usr/bin/node9',
1 verbose cli   '/home/adam/.npm-packages/bin/npm',
1 verbose cli   'i',
1 verbose cli   '-g',
1 verbose cli   '-S',
1 verbose cli   'aspiers/gatsby#sort-chunks' ]
2 info using npm@6.5.0
3 info using node@v9.11.1
4 verbose npm-session e5294cb75ceedf0e
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly pacote git manifest for undefined@github:aspiers/gatsby#sort-chunks fetched in 907ms
8 timing stage:loadCurrentTree Completed in 1032ms
9 silly install loadIdealTree
10 silly install cloneCurrentTreeToIdealTree
11 timing stage:loadIdealTree:cloneCurrentTree Completed in 1ms
12 silly install loadShrinkwrap
13 timing stage:loadIdealTree:loadShrinkwrap Completed in 2ms
14 silly install loadAllDepsIntoIdealTree
15 timing stage:rollbackFailedOptional Completed in 1ms
16 timing stage:runTopLevelLifecycles Completed in 1037ms
17 verbose stack Error: Can't install github:aspiers/gatsby#a00aa4eed4c4d821544d33a85fe3caca36ad9bde: Missing package name
17 verbose stack     at hasMinimumFields (/home/adam/.npm-packages/lib/node_modules/npm/lib/install/validate-args.js:26:15)
17 verbose stack     at Array.<anonymous> (/home/adam/.npm-packages/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
17 verbose stack     at LOOP (/home/adam/.npm-packages/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:14)
17 verbose stack     at chain (/home/adam/.npm-packages/lib/node_modules/npm/node_modules/slide/lib/chain.js:20:5)
17 verbose stack     at /home/adam/.npm-packages/lib/node_modules/npm/lib/install/validate-args.js:16:5
17 verbose stack     at /home/adam/.npm-packages/lib/node_modules/npm/node_modules/slide/lib/async-map.js:52:35
17 verbose stack     at Array.forEach (<anonymous>)
17 verbose stack     at /home/adam/.npm-packages/lib/node_modules/npm/node_modules/slide/lib/async-map.js:52:11
17 verbose stack     at Array.forEach (<anonymous>)
17 verbose stack     at asyncMap (/home/adam/.npm-packages/lib/node_modules/npm/node_modules/slide/lib/async-map.js:51:8)
17 verbose stack     at module.exports (/home/adam/.npm-packages/lib/node_modules/npm/lib/install/validate-args.js:15:3)
17 verbose stack     at Array.<anonymous> (/home/adam/.npm-packages/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
17 verbose stack     at LOOP (/home/adam/.npm-packages/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:14)
17 verbose stack     at chain (/home/adam/.npm-packages/lib/node_modules/npm/node_modules/slide/lib/chain.js:20:5)
17 verbose stack     at Installer.loadAllDepsIntoIdealTree (/home/adam/.npm-packages/lib/node_modules/npm/lib/install.js:477:3)
17 verbose stack     at Array.<anonymous> (/home/adam/.npm-packages/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
18 verbose cwd /home/adam
19 verbose Linux 4.12.14-lp150.12.7-default
20 verbose argv "/usr/bin/node9" "/home/adam/.npm-packages/bin/npm" "i" "-g" "-S" "aspiers/gatsby#sort-chunks"
21 verbose node v9.11.1
22 verbose npm  v6.5.0
23 error Can't install github:aspiers/gatsby#a00aa4eed4c4d821544d33a85fe3caca36ad9bde: Missing package name
24 verbose exit [ 1, true ]

Same thing happens with npm i -S aspiers/gatsby.

Platform Info

$ npm --versions
{ 'adamspiers.org': '1.0.0',                                                                                                                       
  npm: '6.5.0',
  ares: '1.14.0',
  cldr: '32.0.1',
  http_parser: '2.8.0',
  icu: '60.2',
  modules: '59',
  napi: '3',
  nghttp2: '1.31.1',
  node: '9.11.1',
  openssl: '1.1.0h-fips',
  tz: '2017c',
  unicode: '10.0',
  uv: '1.19.2',
  v8: '6.2.414.46-node.23',
  zlib: '1.2.11' }
$ node -p process.platform
linux

(Lars Willighagen) #2

Gatsby is a monorepo, and has no name field in the root package.json. It currently isn’t possible to install a subdirectory directly from a git URL, although it is being discussed somewhere. I can’t find where at the moment, but I believe the preliminary conclusion was that it can’t simply be done, because of a syntax limitation.


(Adam Spiers) #3

Ah I see, thanks a lot! But perhaps npm’s error message could be made a little more informative? It seems quite cryptic currently.