I don't have a webpack config, as I am using the webpacker gem for Ruby on Rails. I am using a default configuration with the ERB loader.
This
I expect to be able to run the webpack-dev-server.
When attempting to run the webpack-dev-server, an error is being thrown:
./bin/webpack-dev-server
$ C:\Users\jonas\projects\apps\nativegap\node_modules\webpack-dev-server\bin\webpack-dev-server.js:405
throw e;
^
TypeError: Cannot read property 'compile' of undefined
at addCompilerHooks (C:\Users\jonas\projects\apps\nativegap\node_modules\webpack-dev-server\lib\Server.js:71:16)
at new Server (C:\Users\jonas\projects\apps\nativegap\node_modules\webpack-dev-server\lib\Server.js:81:5)
at startDevServer (C:\Users\jonas\projects\apps\nativegap\node_modules\webpack-dev-server\bin\webpack-dev-server.js:398:14)
at processOptions (C:\Users\jonas\projects\apps\nativegap\node_modules\webpack-dev-server\bin\webpack-dev-server.js:361:5)
at Object.<anonymous> (C:\Users\jonas\projects\apps\nativegap\node_modules\webpack-dev-server\bin\webpack-dev-server.js:504:1)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
Note that I am using this package with the webpacker gem for Ruby on Rails. However, the same happens when running webpack-dev-server.
webpack-dev-server 3.x is only compatible with webpack 4.x, as the peer dependencies already warn you about.
I am facing the same error.
@aruprakshit I was able to fix it by downgrading webpack-dev-server to 2.x
Downgrading webpack-dev-server to 3.0.0 works fine.
1 - Upgrade webpack to v4, you must change the webpack.config.js file for compatibility. or
2 - Downgrade webpack-dev-server to exactly v3.0.0 as @Nufeen said.
Hey I am facing with the same problem too
@byamasu-patrick for me it was solved by installing webpack-dev-server. I guess it was included in webpack before.
Kind of sketch because when I downgrade npm gives a notification that there is a high severity vulnerability
npm WARN [email protected] requires a peer of webpack@^4.0.0-beta.1 but none is installed. You must install peer dependencies yourself.
added 910 packages from 590 contributors and audited 9040 packages in 16.697s
found 1 high severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
Downgrading version does fix this with vue-cli
Locking to 3.0.0 worked for me:
"webpack-dev-server": "3.0.0"
Most helpful comment
webpack-dev-server 3.x is only compatible with webpack 4.x, as the peer dependencies already warn you about.