A brand new Rails 6.1.4.1 app fails to run bin/webpack-dev-server
with the following error:
/rails_app/node_modules/webpack-cli/bin/utils/prompt-command.js:46
return func(...args);
^
TypeError: Class constructor ServeCommand cannot be invoked without 'new'
at runWhenInstalled (/rails_app/node_modules/webpack-cli/bin/utils/prompt-command.js:46:9)
at promptForInstallation (/rails_app/node_modules/webpack-cli/bin/utils/prompt-command.js:140:10)
at /rails_app/node_modules/webpack-cli/bin/cli.js:32:43
at Object.<anonymous> (/rails_app/node_modules/webpack-cli/bin/cli.js:366:3)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Module.load (internal/modules/cjs/loader.js:937:32)
at Function.Module._load (internal/modules/cjs/loader.js:778:12)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18)
This reported issue shows that webpack-dev-server is no longer compatible with Webpacker 5. This means that there are two fixes available to us:
You can do this by updating your package.json
file:
"webpack-dev-server": "~3"
This version is not yet released and the upgrade path is not simple.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With