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

Projects
None yet
@Ankainnn
Copy link

Ankainnn commented Feb 27, 2018

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

This comment has been minimized.

Copy link

Morganjackson commented Feb 28, 2018

I'm seeing the same thing with:

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

@Terit

This comment has been minimized.

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

This comment has been minimized.

Copy link

freestylebit commented Feb 28, 2018

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

@smgilchrist

This comment has been minimized.

Copy link

smgilchrist commented Feb 28, 2018

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

@mashdots

This comment has been minimized.

Copy link

mashdots commented Feb 28, 2018

Ruby: 2.3.3
Rails: 5.1.5
Node: 6.11.5

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

@ghost

This comment has been minimized.

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

This comment has been minimized.

Copy link

travisdmathis commented Mar 2, 2018

Ditto, downgrading solved the problem. Thanks.

@roberttravispierce

This comment has been minimized.

Copy link

roberttravispierce commented Mar 2, 2018

I experienced the same. Thank you for this solution.

@pspgbhu

This comment has been minimized.

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

This comment has been minimized.

Copy link
Collaborator

gauravtiwari commented Mar 3, 2018

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

@nodox

This comment has been minimized.

Copy link

nodox commented Mar 6, 2018

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

@suhomlineugene

This comment has been minimized.

Copy link

suhomlineugene commented Mar 6, 2018

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

Downgrade webpack dev server
yarn upgrade webpack-dev-server@^2.11.1

rails/webpacker#1303 (comment)
@LukyVj

This comment has been minimized.

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

This comment has been minimized.

Copy link

gavin667 commented Mar 9, 2018

Yep downgrading to 2.11.1 works. Rails 5.1.5

@coderhs

This comment has been minimized.

Copy link

coderhs commented Mar 9, 2018

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

@ytbryan

This comment has been minimized.

Copy link
Contributor

ytbryan commented Mar 10, 2018

Yes, #1316 is on its way

@LySofDev

This comment has been minimized.

Copy link

LySofDev commented Mar 10, 2018

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

This comment has been minimized.

Copy link

jeremywrowe commented Mar 12, 2018

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

This comment has been minimized.

Copy link
Collaborator

gauravtiwari commented Mar 12, 2018

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

@jeremywrowe

This comment has been minimized.

Copy link

jeremywrowe commented Mar 13, 2018

@gauravtiwari Awesome 👏

v9n added a commit to notyim/notyim that referenced this issue Mar 14, 2018

@b1tn3r

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Collaborator

gauravtiwari commented Apr 2, 2018

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

@hqsiswiliam

This comment has been minimized.

Copy link

hqsiswiliam commented Apr 12, 2018

Same issue, same solution!

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

@306-san 306-san referenced this issue May 16, 2018

Closed

React導入 #9

@shionphan

This comment has been minimized.

Copy link

shionphan commented May 29, 2018

Same issue, same solution. Thanks for all

@ImCharmainejoy

This comment has been minimized.

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

This comment has been minimized.

Copy link

sevenseacat commented Jan 8, 2019

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

This comment has been minimized.

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

This comment has been minimized.

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
You can’t perform that action at this time.