npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

NPM ci undefined failure when `name` field missing from package-lock.json

What I Wanted to Do

Run npm ci successfully

What Happened Instead

npm fails with the following error:

npm ERR! Cannot read property 'length' of undefined
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/stieg/.npm/_logs/2019-08-17T01_05_46_511Z-debug.log

Reproduction Steps

Demo File:

  "name": "foo",
  "devDependencies": {
    "lerna": "3.16.4"
  "scripts": {
    "postinstall": "echo POST INSTALL STEP"
  1. In an empty directory drop in the package.json file above
  2. Run npm install && npm ci. Things will work
  3. Edit package.json and remove the name field.
  4. Run npm install && npm ci. Things will fail.


On the second run the lack of a name field means the package-lock.json file will not get a name field. This appears to be required whenever a postinstall hook is defined. This is what appears to cause the failure.

Seems related to npm ci fails with obscure error on nested packages if package.json omits name

Platform Info

$ npm --versions
$ node -p process.platform