Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 tasks
yilmazbingo opened this issue Oct 11, 2020 · 21 comments
Closed
2 tasks

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

yilmazbingo opened this issue Oct 11, 2020 · 21 comments

Comments

@yilmazbingo
Copy link

yilmazbingo commented Oct 11, 2020

  • Operating System: kali-2020

  • Node Version: v10.21.0

  • NPM Version: 6.14.7

  • webpack Version: ^5.0.0

  • webpack-dev-server Version:^3.11.0"

  • This is a bug

  • This is a modification request

Code

Expected Behavior

webpack-dev-server should compile

Actual Behavior

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

webpack-dev-server is dependent on the webpack-cli. looks like it has been updated 13 hours ago to version 4.0.0 so its folder structure has changes. here is the current folder structure:
webpack-cli

this is the older folder structure i just created a few days ago:
Screen Shot 2020-10-11 at 4 15 54 AM

@deleonio
Copy link

Yes - webpack-dev-server does not work with webpack-cli v4

@wood1986
Copy link
Contributor

Same there. But when will it get fixed?

@snitin315
Copy link
Member

Can you try webpack serve ?

@wood1986
Copy link
Contributor

@snitin315 What is the difference between webpack-dev-server and webpack serve? Does it mean I do not need webpack-dev-server when I use webpack v5?

@snitin315
Copy link
Member

Yes webpack-cli v4 comes with out of box support of @webpack-cli/serve which means you can use webpack serve to invoke the webpack-dev-server.

@alexander-akait
Copy link
Member

We need to add try/catch to our cli when we require module from webpack-cli and output a warning to use webpack serve to run webpack dev server

@malcolm-kee
Copy link
Contributor

Able to reproduce the bug in Windows.

@navirick
Copy link

Can you provide an example of how we replace the use of devServer in our webpack config file with serve?

@alexander-akait
Copy link
Member

Please update webpack-cli to v4 and use webpack serve to run webpack-dev-server

@mybrainishuge
Copy link

How are environment options passed to webpack serve when exporting a function in the webpack config? With webpack-dev-server, I passed environment variables:

webpack-dev-server --env.mode development

Passing the same argument to webpack serve errors:

[webpack-cli] Unknown argument: --env.mode
[webpack-cli] Unknown argument: development

I'm not seeing how to pass anything other than booleans to webpack serve, but I want to pass strings:

webpack serve --env mode

@navirick
Copy link

I would hope since it seems it is understood what is needed for webpack-dev-server to work with webpack 5, the authors would put a fix in ASAP to resolve this issue. I too am trying webpack serve, and am not able to get it to work. In the future, when suggesting a change like this, it would be extremely beneficial to provide a simple example of how it should work. As it is, it seems this requires knowledge or figuring out how serve works which is different than how webpack-dev-server works.

@Jerboas86
Copy link

Please update webpack-cli to v4 and use webpack serve to run webpack-dev-server

I also had to reinstall webpack dev server (v3.11.0) to make it work.

sue445 added a commit to sue445/primap that referenced this issue Oct 12, 2020
webpack-dev-server doesn't work at webpack-cli v4

c.f. webpack/webpack-dev-server#2759
@wanliyunyan
Copy link

wanliyunyan commented Oct 13, 2020

"dev": "webpack server --env development"

"webpack": "^5.0.0",
"webpack-cli": "^4.0.0",
"webpack-dev-server": "^3.11.0",

ERROR in main
Module not found: Error: Can't resolve 'server' in '*********'

webpack 5.0.0 compiled with 1 error in 521 ms

what should I do?

@mybrainishuge
Copy link

mybrainishuge commented Oct 13, 2020

@wanliyunyan Should be webpack serve not server:

"dev": "webpack serve --mode development --env development"

@wanliyunyan
Copy link

@wanliyunyan Should be webpack serve not server:

"dev": "webpack serve --mode development --env development"

thank you,.............

@YahzeeSkellington
Copy link

YahzeeSkellington commented Oct 13, 2020

The migration guide says we should be using webpack-dev-server instead of serve:

``
serve ↦ serve is removed in favor of DevServer


[https://webpack.js.org/migrate/5/]{https://webpack.js.org/migrate/5/)

Furthermore HMR no longer works when I switch to 'serve'. The browser console logo shows [HMR] Waiting for update signal from WDS... but nothing happens. Going back to Webpack 4

@chenxsan
Copy link
Member

@YahzeeSkellington

That serve/devServer mentioned in migration is a configure defined in webpack configuration, not the one used in CLI.

Regarding the HMR, you might have the similar issue as #2758 if you have browserslist in your project.

@Yammoe
Copy link

Yammoe commented Oct 14, 2020

@YahzeeSkellington as @chenxsan said, I removed "browsersList" from package.json and hot reload work well.

@randomco
Copy link

webpack serve did not serve well :) Ran into more errors. Finally reverted to
"webpack": "^4.41.3",
"webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.9.0"

@webpack webpack locked as off-topic and limited conversation to collaborators Oct 14, 2020
@alexander-akait
Copy link
Member

alexander-akait commented Oct 14, 2020

Please stop spam, we known about the problem and we provide solution above, we need additional try/catch in our bin and provide friendly error

@alexander-akait
Copy link
Member

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests