2

When I try to run webpack-dev-server it gives the error.

Error: Cannot find module 'webpack-cli/bin/config-yargs'

I looked around and found that you had to change the script to "webpack serve" and did that but then it gives me the following:

**[webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.

  • configuration.devtool should match pattern "^(inline-|hidden-|eval-)?(nosources-)?(cheap-(module-)?)?source-map$". BREAKING CHANGE since webpack 5: The devtool option is more strict. Please strictly follow the order of the keywords in the pattern.**

My system is Windows 10 Pro and the versions are the following:

  • webpack: 5.6.0
  • webpack-cli: 4.2.0
  • webpack-dev-server: 3.11.0

I've also tried including "inline: false" into the devServer object in webpack.config.js but to no avail.

hank
  • 21
  • 2

1 Answers1

0

just few step:

  • add script "dev": "webpack serve"
  • set devtool: 'eval-source-map' in webpack.config.js
  • then run npm run dev or npx webpack serve

webpack v5 && webpack-cli v4 should use webpack serve instead of webpack-dev-server

if you run npx webpack serve come out

configuration.devtool should match pattern "^(inline-|hidden-|eval-)?(nosources-)?(cheap-(module-)?)?source-map$". BREAKING CHANGE since webpack 5: The devtool option is more strict. Please strictly follow the order of the keywords in the pattern.**

you can set devtool: 'eval-source-map' in webpack.config.js

usually to balance speed and debugging:

  • in development mode we use devtool: 'eval-source-map'
  • in production mode we use devtool: 'cheap-module-source-map'

you can also return webpack v4 && webpack-cli v3 or try npm i webpack-dev-server@4.0.0-beta.0 -D see https://github.com/webpack/webpack-dev-server/releases/tag/v4.0.0-beta.0

more issues you can see

redstar08
  • 1
  • 1