score:0

i think it's related to webpack version only. can you please update the webpack, webpack-cli and webpack-dev-server with latest version and check it.

hope this will work for you!

score:0

in package.json use "dev":"webpack serve" instead of "webpack-dev-server"

score:0

don't play with the webpack module for a while you are learning because it is tricky to do this stuff.

i have the same problem that you listed before

// change your mode to development in package.json
// make everything in devdependencies
{
  "name": "timer",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "build": "webpack",
    "start": "webpack-dev-server"
  },
  "babel": {
    "presets": [
      "@babel/preset-env",
      "@babel/preset-react"
    ]
  },
  "keywords": [],
  "author": "",
  "license": "isc",
  "dependencies": {
    "react": "^17.0.2",
    "react-dom": "^17.0.2"
  },
  "devdependencies": {
    ...
  }
}

in your webpack.config

const path = require('path')
const htmlwebpackplugin = require('html-webpack-plugin')

module.exports = {
  entry: './app/index.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'index_bundle.js'
  },
    module: {
      rules: [
        { test: /\.(js)$/, use: 'babel-loader' },
        { test: /\.css$/, use: [ 'style-loader', 'css-loader' ]}
      ]
    },
  mode: 'development',
  plugins: [
    new htmlwebpackplugin({
      template: 'app/index.html'
    })
  ]
}

this may work for you.

score:1

if you have the error for the issues described here: https://github.com/webpack/webpack-dev-server/issues/2029

i wrote a python script to fix the problem until it's patched.

you can just add the command to your package.json script after adding the file to your project (assuming you have python installed).

https://github.com/bigbizze/fixwebpackerror-cannot-find-module-webpack-cli-bin-config-yargs

score:1

try the following. its worked for me

"scripts": { "lint": "eslint ./", "build": "webpack", "dev": "webpack serve" },

score:1

i had the same problem, try npm install --save-dev webpack webpack-cli webpack-dev-server webpack-merge

score:2

in your package.json file just change "dev": "webpack-dev-server" to "dev": "webpack serve"

score:3

i had the same problem and it was because the webpack version was not stable i used the lower version and the problem was solved

npm install webpack@4.32.2 --save-dev

npm install webpack-cli@3.3.2 --save-dev

npm install webpack-dev-server@3.5.1 --save-dev


Related Query

More Query from same tag