Webpacker: Cannot read property 'compile' of undefined when running ./bin/webpack-dev-server

Created on 27 Feb 2018  ยท  29Comments  ยท  Source: rails/webpacker

ruby 2.3.4
rails 5.1.4
node 8.9.4

I get next error when trying to run ./bin/webpack-dev-server

/home/project/node_modules/webpack-dev-server/bin/webpack-dev-server.js:405
    throw e;
    ^

TypeError: Cannot read property 'compile' of undefined
    at addCompilerHooks (/home/project/node_modules/webpack-dev-server/lib/Server.js:71:16)
    at new Server (/home/project/node_modules/webpack-dev-server/lib/Server.js:81:5)
    at startDevServer (/home/project/node_modules/webpack-dev-server/bin/webpack-dev-server.js:398:14)
    at processOptions (/home/project/node_modules/webpack-dev-server/bin/webpack-dev-server.js:361:5)
    at Object.<anonymous> /home/project/node_modules/webpack-dev-server/bin/webpack-dev-server.js:504:1)
    at Module._compile (module.js:662:30)
    at Object.Module._extensions..js (module.js:673:10)
    at Module.load (module.js:575:32)
    at tryModuleLoad (module.js:515:12)
    at Function.Module._load (module.js:507:3)

Does anyone faced with the same error?

Most helpful comment

I was having the same issue with:
Ruby: 2.4.1
Rails: 5.1.2
Node: 8.9.4

I was following the Readme instructions to upgrade(yarn upgrade webpack-dev-server --latest), however this installed webpack-dev-server v3.1.0. When I downgraded to v2.11.1 (yarn upgrade webpack-dev-server@^2.11.1) my dev server worked again!

All 29 comments

I'm seeing the same thing with:

Ruby: 2.5.0
Rails: 5.2.0.rc1
Node: v8.9.4

I was having the same issue with:
Ruby: 2.4.1
Rails: 5.1.2
Node: 8.9.4

I was following the Readme instructions to upgrade(yarn upgrade webpack-dev-server --latest), however this installed webpack-dev-server v3.1.0. When I downgraded to v2.11.1 (yarn upgrade webpack-dev-server@^2.11.1) my dev server worked again!

I can confirm. Sticking with 2.11.1 works for the interim.

Thanks, Terit. I was running into the same issue and that fixed it.
Rails 5.2.0.rc1
Node 9.6.1

Ruby: 2.3.3
Rails: 5.1.5
Node: 6.11.5

Downgrading to v2.11.1 did the trick! Thank you!

Node: 9.6.1
Rails: 5.1.5
Ruby: 2.5.0

Downgrading fixed the issue for me too.
Thank you

Ditto, downgrading solved the problem. Thanks.

I experienced the same. Thank you for this solution.

I met the same issue, and downgrading webpack-dev-server to 2.11.1 fixed it.
Thanks!

Thanks everyone. We will update Webpacker to use webpack 4.0 soon - in meantime please use the supported dev server version.

Had the same issue. @Terit solution worked for me.

Had this issue too/ @Terit solution helps me

I confirm that @Terit solution works!

Yep downgrading to 2.11.1 works. Rails 5.1.5

Sadly downgrading is the only solution, for now, any permanent fix in the pipeline?

Ruby 2.4.0
Node 8.9.4
Rails 5.1.5

Received error with [email protected] included by the new Rails project generator. Downgrading to version 2.11.1 fixed the issue.

It seems like there should be some version ranges specified going to ease confusion. I'd be more than happy to help with implementation.

My proposal is to

  • change documentation - Depending on webpack version, you may not be able to use webpack-dev-sever@latest.
  • maybe have a check / warning to help new folks figure out what is going on when the specified versions don't work together.

Happy to help out, and I know that there is a shift to webpack 4 where this won't be an issue soon, but that's not to say there won't be the same issue in the future.

Released 3.3.1 that restricts dev server to 2.x.x

@gauravtiwari Awesome ๐Ÿ‘

I was having issues with both webpack v4 and webpack-dev-server v3 and the only solutions I've seen from threads has been to downgrade both of them. Is this something that no one has figured out how to migrate or is there actually something wrong with the new versions and/or webpack-cli?

Is this something that no one has figured out how to migrate or is there actually something wrong with the new versions and/or webpack-cli?

Going to close this one, since this isn't an issue with the current version of webpacker.

Same issue, same solution!

Same issue, same solution. Thanks for all

Operating System: Windows
Node Version: 8.9.4
NPM Version: 6.5.0
webpack Version: 3.6.0
webpack-dev-server Version: 2.9.0

i'm having the same problem of
cannot destructure property compile of 'undefined' or 'null'
and my solution is at https://github.com/webpack/webpack-dev-server/issues/1259 @smackgg

with this command: npm install --save-dev [email protected]

The problem with downgrading is that there's a CVE for webpack-dev-server < 3.11.1 - https://nvd.nist.gov/vuln/detail/CVE-2018-14732

use [email protected] version
npm i [email protected] --save dev
when terminal shows npm audit fix then do not use this otherwise npm will install latest webpack-dev-server

use [email protected] version
npm i [email protected] --save dev
when terminal shows npm audit fix then do not use this otherwise npm will install latest webpack-dev-server

Reverting back to version 2.9.1 still shows the security hole:

# Run  npm install --save-dev [email protected]  to resolve 1 vulnerability
SEMVER WARNING: Recommended action is a potentially breaking change
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ High          โ”‚ Missing Origin Validation                                    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Package       โ”‚ webpack-dev-server                                           โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Dependency of โ”‚ webpack-dev-server [dev]                                     โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Path          โ”‚ webpack-dev-server                                           โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ More info     โ”‚ https://nodesecurity.io/advisories/725                       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
Was this page helpful?
0 / 5 - 0 ratings

Related issues

towry picture towry  ยท  3Comments

ilrock picture ilrock  ยท  3Comments

itay-grudev picture itay-grudev  ยท  3Comments

ijdickinson picture ijdickinson  ยท  3Comments

ytbryan picture ytbryan  ยท  3Comments