Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Ankainnn opened this issue Feb 27, 2018 · 29 comments

Comments

@Ankainnn
Copy link

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?

@Morganjackson
Copy link

I'm seeing the same thing with:

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

@Terit
Copy link

Terit commented Feb 28, 2018

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!

@freestylebit
Copy link

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

@smgilchrist
Copy link

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

@mashdots
Copy link

Ruby: 2.3.3
Rails: 5.1.5
Node: 6.11.5

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

@ghost
Copy link

ghost commented Mar 1, 2018

Node: 9.6.1
Rails: 5.1.5
Ruby: 2.5.0

Downgrading fixed the issue for me too.
Thank you

@travisdmathis
Copy link

Ditto, downgrading solved the problem. Thanks.

@roberttravispierce
Copy link

I experienced the same. Thank you for this solution.

@pspgbhu
Copy link

pspgbhu commented Mar 3, 2018

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

@gauravtiwari
Copy link
Member

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

@nodox
Copy link

nodox commented Mar 6, 2018

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

@suhomlineugene
Copy link

Had this issue too/ @Terit solution helps me

dschmura added a commit to dschmura/rails5template that referenced this issue Mar 6, 2018
Sinetheta added a commit to Sinetheta/payment_request_api that referenced this issue Mar 7, 2018
yarn upgrade webpack-dev-server@^2.11.1

rails/webpacker#1303 (comment)
@LukyVj
Copy link

LukyVj commented Mar 7, 2018

I confirm that @Terit solution works!

dpickett added a commit to LaunchAcademy/make_it_so that referenced this issue Mar 7, 2018
@gavin667
Copy link

gavin667 commented Mar 9, 2018

Yep downgrading to 2.11.1 works. Rails 5.1.5

@coderhs
Copy link

coderhs commented Mar 9, 2018

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

@ytbryan
Copy link
Contributor

ytbryan commented Mar 10, 2018

Yes, #1316 is on its way

@LySofDev
Copy link

Ruby 2.4.0
Node 8.9.4
Rails 5.1.5

Received error with webpack-dev-server@3.1.1 included by the new Rails project generator. Downgrading to version 2.11.1 fixed the issue.

@rails rails deleted a comment from inkhrt Mar 11, 2018
GPif added a commit to GPif/test_wttj that referenced this issue Mar 11, 2018
@jeremywrowe
Copy link

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.

@gauravtiwari
Copy link
Member

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

@jeremywrowe
Copy link

@gauravtiwari Awesome 👏

v9n pushed a commit to yeo/notyim that referenced this issue Mar 14, 2018
@b1tn3r
Copy link

b1tn3r commented Mar 26, 2018

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?

@ytbryan
Copy link
Contributor

ytbryan commented Mar 26, 2018

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?

@gauravtiwari
Copy link
Member

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

@hqsiswiliam
Copy link

Same issue, same solution!

ledermann added a commit to ledermann/docker-rails that referenced this issue May 14, 2018
@shionphan
Copy link

Same issue, same solution. Thanks for all

@ImCharmainejoy
Copy link

ImCharmainejoy commented Dec 29, 2018

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 webpack/webpack-dev-server#1259 @smackgg

with this command: npm install --save-dev webpack-dev-server@2.9.7

@sevenseacat
Copy link

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

@niteshcse14
Copy link

niteshcse14 commented Jan 9, 2019

use webpack-dev-server@2.9.1 version
npm i webpack-dev-server@2.9.1 --save dev
when terminal shows npm audit fix then do not use this otherwise npm will install latest webpack-dev-server

@stugoo
Copy link

stugoo commented Jan 9, 2019

use webpack-dev-server@2.9.1 version
npm i webpack-dev-server@2.9.1 --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 webpack-dev-server@3.1.14  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                       │
└───────────────┴──────────────────────────────────────────────────────────────┘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests