Tag Archives: Webpack compilation Error

[Solved] Webpack compilation Error: Cannot find module’webpack-cli/bin/config-yargs’

Problems encountered during operation npm run dev: Error: Cannot find module’webpack-cli/bin/config-yargs’

// package.json
​
"devDependencies": {
    "webpack": "^5.2.0",
    "webpack-cli": "^4.1.0",
    "webpack-dev-server": "^3.11.0"
}

 

Problem solving reference: Error: Cannot find module’webpack-cli/bin/config-yargs’ #1948

If you upgrade webpack to 5. *, and webpack cli to 4. *, an error will be reported:

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

Temporary solution: Back off webpack cli to version 3. * for example:

"webpack-cli": "^ 3.3.12"

  Solution:

  1. Uninstall the current webpack-cli npm uninstall webpack-cli

  2. Install webpack-cli 3.* version npm install webpack-cli@3 -D

// package.json
​
"devDependencies": {
    "webpack": "^5.2.0",
    "webpack-cli": "^3.3.12",
    "webpack-dev-server": "^3.11.0"
}