Webpack-dev-server: Cannot read property 'length' of undefined during npm install

Created on 21 Nov 2020  路  9Comments  路  Source: webpack/webpack-dev-server

THIS IS A NPM BUG

Temporary solutions:

  • Use --legacy-peer-deps
  • Use Node.js 14.x / NPM 6.x

Initial Issue

  • Operating System: Windows 10 64bit
  • Node Version: 15.2.1
  • NPM Version: 7.0.8
  • webpack Version: 5.6.0
  • webpack-dev-server Version: (latest)
  • Browser: -

  • [x] This is a bug
  • [ ] This is a modification request

Code

I want to install webpack-dev-server with: npm i -D webpack-dev-server

Expected Behavior

Succesful installation without any errors.

Actual Behavior

I receive an error during installation.

npm ERR! code ERESOLVE
npm ERR! Cannot read property 'length' of undefined

2020-11-21T14_49_45_952Z-debug.log

For Bugs; How can we reproduce the behavior?

Create a new folder, run npm i -D webpack webpack-cli webpack-dev-server

I can install webpack and webpack-cli without errors.

Most helpful comment

Probably related: npm/cli#1749

And indeed, --legacy-peer-deps allows webpack-dev-server to be installed.

All 9 comments

Seeing the same issue on macOS.
Node 15.2.1
npm 7.0.10
webpack 5.6.0

2020-11-22T15_22_46_154Z-debug.log

Probably related: npm/cli#1749

And indeed, --legacy-peer-deps allows webpack-dev-server to be installed.

Yes, it is npm bug

Not sure how we can fix it on our side

I have the same issue, I downgrade my node version 14.15.1 using nvm and worked. This is not a solution, but can help if someone don't know that to do.

Please open an issue again in npm, their latest innovations are just crazy, a lot of regressions, even it is require --legacy-peer-deps they should provide friendly error, not like Cannot read property 'length' of undefined, we can't fix something here, even you will write +1 or same here will not allow to solve the issue

I updated my initial post to provide temporary solutions for others who will search for this error.

This fixed it for me for now at least : npm i --save-dev webpack-dev-server --legacy-peer-deps

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wojtekmaj picture wojtekmaj  路  3Comments

mrdulin picture mrdulin  路  3Comments

mischkl picture mischkl  路  3Comments

MJ111 picture MJ111  路  3Comments

movie4 picture movie4  路  3Comments