webpack-dev-server: Error: Cannot find module 'webpack-cli/bin/config-yargs'
-
Operating System: Mac OS
-
Node Version: 10.15.1
-
NPM Version: 6.4.1
-
webpack Version: 4.34.0
-
webpack-dev-server Version: 3.2.1
-
This is a bug…?
-
This is a modification request
Code
// webpack.config.js
const path = require('path');
const config = require('./webpack.dev.config');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const newConfig = Object.assign({}, config);
newConfig.entry = ['@babel/polyfill', './app/features/Certifications/index', 'webpack/hot/only-dev-server'];
newConfig.output = {
filename: 'webpack-certifications-bundle.js',
path: path.resolve('../app/assets/webpack'),
publicPath: '/',
};
newConfig.devServer = {
historyApiFallback: true,
hot: true,
open: true,
openPage: 'dashboard',
port: 9000,
proxy: {
'/api': {
target: 'http://localhost:9010',
secure: false,
},
},
publicPath: '/',
};
newConfig.plugins.push(new HtmlWebpackPlugin());
module.exports = newConfig;
module.exports.devtool = 'cheap-module-eval-source-map';
// package.json
scripts: {
"dev:cert:webpack": "NODE_ENV=development webpack-dev-server --config webpack.dev.certifications.config.js"
}
Expected Behavior
Running npm run dev:cert:webpack
starts webpack dev server.
Actual Behavior
~/src/projects/client$ npm run dev:cert:webpack
> acl-project-manager@0.0.1 dev:cert:webpack /Users/jamie/src/projects/client
> NODE_ENV=development webpack-dev-server --config webpack.config.js
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module 'webpack-cli/bin/config-yargs'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/Users/jamie/src/projects/client/node_modules/webpack-dev-server/bin/webpack-dev-server.js:77:1)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! acl-project-manager@0.0.1 dev:cert:webpack: `NODE_ENV=development webpack-dev-server --config webpack.dev.certifications.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the acl-project-manager@0.0.1 dev:cert:webpack script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/jamie/.npm/_logs/2019-06-14T23_23_20_044Z-debug.log
If I upgrade to webpack-dev-server 3.7.1, this error does not occur.
Thank you for your help.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 9
- Comments: 46 (14 by maintainers)
Links to this issue
Commits related to this issue
- Downgrade webpack-dev-server because of webpack/webpack-dev-server/issues/2029 — committed to nya1/updown-status-page by nya1 4 years ago
- Downgrade webpack-dev-server because of webpack/webpack-dev-server/issues/2029 — committed to UrbaniakM/vuejs-todo-app by UrbaniakM 4 years ago
- Update webpack-cli Note: https://github.com/webpack/webpack-dev-server/issues/2029#issuecomment-585207461 — committed to nickovchinnikov/react-js-tutorial by vvscode 4 years ago
Please use
webpack serve
for run webpack-dev-serverI ran into this issue after updating webpack-cli from:
webpack-cli ^3.2.1 → ^3.3.9
I fixed it by changing:
node_modules\webpack-dev-server\bin\webpack-dev-server.js
Line 84:
require('webpack-cli/bin/config-yargs')(yargs);
To:require('webpack-cli/bin/config/config-yargs')(yargs);
Line 92:
const config = require('webpack-cli/bin/convert-argv')(yargs, argv, {
To:const config = require('webpack-cli/bin/utils/convert-argv')(yargs, argv, {
This is broken again when using
webpack-cli
4.0.0 (in beta). There’s onlycli.js
left insidewebpack-cli/bin
.Need update
webpack-cli
to v4 (stable) and changewebpack-dev-server
bin in package.json onwebpack serve
:Old:
package.json
New:
package.json
Please read my answer careful
webpack-dev-server@3.7.1 is OK.
webpack-dev-server@3.7.2 error: Cannot find module ‘yargs’
Same to me:
Works:
@evilebottnawi Your answer is somewhere in the middle of 20-30 replies to this issues. It’s nowhere in the README. The version didn’t change, but somehow the behaviour broke due to a release of an external lib?
Dependabot has bumped cli version for quite a number of projects, so expect a lot of people flocking to this issue and potentially missing a response.
The best way to solve this is just to add a line to the README:
use the webpack-3.3.12 version
npm i webpack-cli@3.3.12
and it should work!webpack-cli@4
this problem still exists runnpm install -D webpack-cli@3
to solve itYes, we are working on bugs in webpack-cli, it will be improved after this
You use old webpack-cli version, please update webpack-cli
Fixed in #1754. Upgrade to
webpack-dev-server
3.3.0 or higher.running 3.3.12 resolved this for me.
npm i webpack-cli@3.3.12
Hi All, having trouble with this as well.
I changed the versions to recommended ones here, but the issue persists.
Just reporting that this is still broken.
Do not upgrade to
"webpack": "~4.44.2"
yet, stay on"webpack-cli": "~3.3.12"
internal/modules/cjs/loader.js:968 throw err; ^
Error: Cannot find module ‘webpack/bin/config-yargs’ Require stack:
webpack-dev-server --hot
npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the reactapp@1.0.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Harsh Agarwal\AppData\Roaming\npm-cache_logs\2020-09-19T03_56_55_540Z-debug.log
Kindly help me with this i cant find solution from past 3 days
npm i webpack-cli
downgraded 4.x => 3.3.12, it’s work
I was trying to run
yarn webpack-dev-server
on an app runningreact-scripts
. I forgot I had usedcreate-react-app
to bootstrap my app.Running
yarn start
fixed the issue.can’t thank you enough for your time 😉
Just change https://github.com/Loligplayer33/Portfolio-Website-2.0/blob/master/package.json#L29 to
^3.3.11
, removepackage-lock.json
and runnpm i
again