Invalid package name warning causes failed install

What I Wanted to Do

Build a docker image and have the build fail if there are errors in the package.json file.

Trying to run npm install with a package name that has a space.

Expectation: I should either get an error when running npm install with a non-zero exit code OR I should see my node_modules folder get created.

What Happened Instead

I get a warning about the package name, install seems to proceed but no node_modules folder is created. I also get an exit code of 0 so everything “seems” fine.

Reproduction Steps

Create a package.json that has a space in the name field.

Add a single dependency.

Run npm install

See the warning about invalid name, and that a package-lock.json file was created, but no dependencies were downloaded.

Details

I have a repo here: https://github.com/Voziv/npm-package-name-bug

Platform Info

$ npm --versions
{
  'jm asdfasdf': '1.0.0',
  npm: '6.11.3',
  ares: '1.15.0',
  brotli: '1.0.7',
  cldr: '35.1',
  http_parser: '2.8.0',
  icu: '64.2',
  llhttp: '1.1.4',
  modules: '72',
  napi: '4',
  nghttp2: '1.39.2',
  node: '12.10.0',
  openssl: '1.1.1c',
  tz: '2019a',
  unicode: '12.1',
  uv: '1.31.0',
  v8: '7.6.303.29-node.16',
  zlib: '1.2.11'
}
$ node -p process.platform
darwin

(Reproduced.)

I found one old report which included an install with an invalid package name: