Skip to content

Error: Cannot find module 'webpack-cli/bin/config-yargs' when use v5 #2424

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

Closed
teabyii opened this issue Feb 3, 2020 · 69 comments
Closed

Error: Cannot find module 'webpack-cli/bin/config-yargs' when use v5 #2424

teabyii opened this issue Feb 3, 2020 · 69 comments

Comments

@teabyii
Copy link

teabyii commented Feb 3, 2020

configYargsPath = 'webpack-cli/bin/config-yargs';

webpack-cli/bin/ no longer exists as of (webpack/webpack-cli@82407e5). This is a blocker for at least webpack-cli@4.0.0-alpha-5. Is there a workaround...?

Originally posted by @JoshuaKGoldberg in #2239 (comment)

@teabyii teabyii changed the title https://github.com/webpack/webpack-dev-server/blob/c9e9178a4882e414a6b9616baa35e8dbf7b2dd75/bin/webpack-dev-server.js#L61 Error: Cannot find module 'webpack-cli/bin/config-yargs' Feb 3, 2020
@alexander-akait
Copy link
Member

alexander-akait commented Feb 3, 2020

Yes, please use webpack serve for 4 version to run webpack dev server, we will remove own binaries in next version, feel free to leave feedback if something doesn't work

@teabyii
Copy link
Author

teabyii commented Feb 3, 2020

image
I used webpack serve,but it didn't work.
This is my package dependencies:

  "devDependencies": {
    "webpack": "^5.0.0-beta.12",
    "webpack-cli": "^4.0.0-beta.1",
    "webpack-dev-server": "^3.10.2"
  }

@teabyii teabyii changed the title Error: Cannot find module 'webpack-cli/bin/config-yargs' Error: Cannot find module 'webpack-cli/bin/config-yargs' when use v5 Feb 3, 2020
@alexander-akait
Copy link
Member

Oh, should be work, can you open issue in webpack-cli?

@teabyii
Copy link
Author

teabyii commented Feb 3, 2020

OK,I will.

@richburdon
Copy link

Same problem here -- any update since Feb 3?

    "webpack": "^4.41.2",
    "webpack-bundle-analyzer": "^3.6.0",
    "webpack-cli": "^3.3.11",
    "webpack-dev-server": "^3.11.0",
    "webpack-merge": "^4.2.2",
    "webpack-version-file-plugin": "^0.4.0",

@belauzas
Copy link

Same problem for me

"devDependencies": {
    "@webpack-cli/init": "^0.3.0",
    "css-loader": "^3.6.0",
    "html-webpack-plugin": "^4.3.0",
    "node-sass": "^4.14.1",
    "sass-loader": "^8.0.2",
    "style-loader": "^1.2.1",
    "webpack": "^4.43.0",
    "webpack-cli": "^4.0.0-beta.8",
    "webpack-dev-server": "^3.11.0",
    "webpack-merge": "^4.2.2"
  }

What does works?
"start": "webpack --config webpack.dev.js",
What does not work?
"start": "webpack-dev-server --config webpack.dev.js",.

@ylemkimon
Copy link
Contributor

Try npm install --save-dev @webpack-cli/serve@beta or yarn add -D @webpack-cli/serve@beta.

@koistya
Copy link

koistya commented Aug 19, 2020

  "devDependencies": {
    "@webpack-cli/serve": "1.0.1-alpha.5",
    "webpack": "5.0.0-beta.26",
    "webpack-cli": "4.0.0-beta.8",
    "webpack-dev-server": "^3.11.0"
  },
$ yarn webpack-cli serve

[webpack-cli] The command moved into a separate package: @webpack-cli/serve

(node:12806) [MODULE_NOT_FOUND] Error: @webpack-cli/package-utils tried to access cross-spawn, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
? Would you like to install @webpack-cli/serve? (That will run npm install -D @webpack-cli/serve) (Y/n) › true

@alexander-akait
Copy link
Member

@koistya do you use yarn?

@merceyz
Copy link

merceyz commented Aug 19, 2020

@evilebottnawi That specific issue was fixed in webpack/webpack-cli#1376 5 months ago, but it hasn't been released yet. And yes, that's a Yarn PnP error message

@alexander-akait
Copy link
Member

@merceyz release webpack-cli will be on this week, you even no need to install @webpack-cli/serve, because it will be out of box, just run webpack serve

@bahtou
Copy link

bahtou commented Sep 6, 2020

Any updates on this?

"@webpack-cli/serve": "^0.2.0",
"webpack": "^5.0.0-beta.29",
"webpack-cli": "^4.0.0-beta.8",
"webpack-dev-server": "^3.11.0"

> webpack-cli serve --config .webpack/index.js

[webpack-cli] The command moved into a separate package: @webpack-cli/serve

? Would you like to install @webpack-cli/serve? (That will run npm install -D @webpack-cli/serve) (Y/n) › true

@ylemkimon
Copy link
Contributor

@bahtou You need to install the beta version of @webpack-cli/serve, see #2424 (comment).

@bahtou
Copy link

bahtou commented Sep 7, 2020

@ylemkimon

"@webpack-cli/serve": "^1.0.1-alpha.5",
"webpack": "^5.0.0-beta.29",
"webpack-cli": "^4.0.0-beta.8",
"webpack-dev-server": "^3.11.0",

> webpack-cli serve --config .webpack/index.js --mode development

Module not found: Error: Can't resolve './index.js'

If I move index.js out of the .webpack directory into root the file is then resolved, but not inside another folder.

@alexander-akait
Copy link
Member

@bahtou fixed in webpack-cli, release will be today/tomorrow, feel free to feedback after new release

@mnjit20
Copy link

mnjit20 commented Sep 14, 2020

any update on this.

@NikoGrano

This comment has been minimized.

@alexander-akait
Copy link
Member

@NicholasBoll What do you mean?

@NikoGrano

This comment has been minimized.

@alexander-akait
Copy link
Member

@NikoGrano How you run webpack-dev-server?

@NikoGrano

This comment has been minimized.

@alexander-akait
Copy link
Member

You need to use webpack serve

@NikoGrano
Copy link

@evilebottnawi Just reporting results: It works! Thank you!

@please-rewrite
Copy link

@evilebottnawi thank you. This really needs to be mentioned in the migrate to webpack 5 doc that is out there

@bahtou
Copy link

bahtou commented Sep 28, 2020

@evilebottnawi I'm getting this error when I updated:

"@webpack-cli/serve": "^1.0.1-rc.0",
"webpack": "^5.0.0-rc.0",
"webpack-cli": "^4.0.0-rc.0",
"webpack-dev-server": "^3.11.0",
> webpack server --config .webpack/index.js --mode development
[webpack-cli] TypeError: Cannot read property 'length' of undefined

Is there a way to get a more verbose output? I am not using .length anywhere in my code base.

@Nethanos
Copy link

I don't know if you are the same team that maintains webpack-dev-server but wouldn't be cool if there is a post or article exposing this change? From my point of view this is some kind of breaking change... Don't you agree? Maybe a commentary on the changelog should be enough.

@iztokf
Copy link

iztokf commented Oct 29, 2020

this is totally frustrating :( tried all suggestions/hacks from all opened issues, but nothing works..

webpack serve --config webpack.config.dev.js

internal/modules/cjs/loader.js:638
    throw err;
    ^
Error: Cannot find module 'webpack-cli/bin/config-yargs'

    "webpack": "^5.1.3",
    "webpack-cli": "^4.1.0",
    "webpack-dev-server": "^3.11.0"

am i missing something? please, help!

@alexander-akait
Copy link
Member

alexander-akait commented Oct 29, 2020

Please use webpack serve instead of using webpack-dev-server in package.json, it was answered a lot of time, but because each every time no wants to read but just writes, the answer constantly disappears

@sacummings91
Copy link

@evilebottnawi I think the issue is we do not get the same functionality with just using webpack serve and there doesn't seem to be any explanation with how to get it working in the same way. Are you going to provide some official documentation of these changes?

@iztokf
Copy link

iztokf commented Oct 29, 2020

Please use webpack serve instead of using webpack-dev-server in package.json

i was trying to run it from cli/console, which still don't work btw; yes, if i run it as package.json script (npm run-script ...) than it's ok; thanks!

@lornally

This comment has been minimized.

@yordan-kanchelov
Copy link

@evilebottnawi is this a temporary solution and if not could you give me an example of how to live-reload on change with the webpack serve

@ferneybaron
Copy link

Hello 👋.
To fix it just do 2 things.

  1. Install
    npm i webpack-cli @webpack-cli/init
  2. add this to your package.json
    "scripts": {
    "start": "webpack-cli serve --mode development"
    },

done!

@sacummings91
Copy link

This seems like a lot of hoops to jump through compared to just doing webpack-dev-server which used to work

pione30 added a commit to pione30/twitter2 that referenced this issue Nov 21, 2020
@SevlaMare
Copy link

"webpack": "^4.44.2",
"webpack-cli": "^4.2.0",
"webpack-dev-server": "^3.11.0"

using
"start": "npx webpack-dev-server --host 0.0.0.0 --port 7000",

works on windows (node 14),
crash on ubuntu 18 (node 12)
using yarn or npm get the same error:

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

works on ubuntu after downgrade to:
"webpack-cli": "^3.3.12"

@PeculiarCode
Copy link

Hello 👋.
To fix it just do 2 things.

  1. Install
    npm i webpack-cli @webpack-cli/init
  2. add this to your package.json
    "scripts": {
    "start": "webpack-cli serve --mode development"
    },

done!

perfect

@alexander-akait
Copy link
Member

Fixed in webpack-dev-server@4-beta.0

@Jaffsterz
Copy link

Jaffsterz commented Nov 29, 2020

Could someone explain what "webpack serve" is actually doing as a command, as opposed to "webpack-dev-server"? It might help people understand why they now have to do this.

Is it running the "webpack-serve" server instead of the "webpack-dev-server" one? (if so, how does it work without that dependency being installed?)

I found plenty of reports saying webpack-dev-server is only in maintenance and that people should use webpack-serve instead, but that doesn't seem to be the case here as web-pack-dev server now appears to have a major new version in beta?

This is all quite confusing for people I think! :(

@AstroProjection
Copy link

It didn't work for me until I specified the 'contentBase' and 'port' property of the devServer and ran the command 'webpack serve --config ./webpack.config.js'

josokinas added a commit to onfido/castor that referenced this issue Jan 21, 2021
MyAiAd added a commit to MyAiAd/Adminator-admin-dashboard that referenced this issue Jan 27, 2021
(except for webpack-cli, which is 3.3.11 to resolve webpack/webpack-dev-server#2424)
ZzAve added a commit to ZzAve/teambalance that referenced this issue Jun 2, 2021
IepIweidieng added a commit to ccns/PttChrome that referenced this issue Aug 25, 2021
webpack-cli@4 requires webpack-dev-server@4:
https://github.com/webpack/webpack-dev-server/releases/tag/v4.0.0-beta.0

* Migrate config from v3 to v4:
https://github.com/webpack/webpack-dev-server/blob/master/migration-v4.md

* Invoke webpack-dev-server using `webpack serve` instead:
"Error: Cannot find module 'webpack-cli/bin/config-yargs' when use v5"
webpack/webpack-dev-server#2424

* Pass production/development env with `--node-env` instead:
https://github.com/webpack/webpack-cli/blob/master/CHANGELOG.md#450-2021-02-02
IepIweidieng added a commit to ccns/PttChrome that referenced this issue Aug 25, 2021
webpack-cli@4 requires webpack-dev-server@4:
https://github.com/webpack/webpack-dev-server/releases/tag/v4.0.0-beta.0

* Migrate config from v3 to v4:
https://github.com/webpack/webpack-dev-server/blob/master/migration-v4.md

* Invoke webpack-dev-server using `webpack serve` instead:
"Error: Cannot find module 'webpack-cli/bin/config-yargs' when use v5"
webpack/webpack-dev-server#2424

* Pass production/development env with `--node-env` instead:
https://github.com/webpack/webpack-cli/blob/master/CHANGELOG.md#450-2021-02-02
IepIweidieng added a commit to ccns/PttChrome that referenced this issue Dec 9, 2021
webpack-cli@4 requires webpack-dev-server@4:
https://github.com/webpack/webpack-dev-server/releases/tag/v4.0.0-beta.0

* Migrate config from v3 to v4:
https://github.com/webpack/webpack-dev-server/blob/master/migration-v4.md

* Invoke webpack-dev-server using `webpack serve` instead:
"Error: Cannot find module 'webpack-cli/bin/config-yargs' when use v5"
webpack/webpack-dev-server#2424

* Pass production/development env with `--node-env` or nothing instead:
https://github.com/webpack/webpack-cli/blob/master/CHANGELOG.md#450-2021-02-02
    * `cross-env` is no longer needed
    * Webpack sets production/development env to 'production' by default
      https://v4.webpack.js.org/configuration/mode/
IepIweidieng added a commit to ccns/PttChrome that referenced this issue Dec 13, 2021
webpack-cli@4 requires webpack-dev-server@4:
https://github.com/webpack/webpack-dev-server/releases/tag/v4.0.0-beta.0

* Migrate config from v3 to v4:
https://github.com/webpack/webpack-dev-server/blob/master/migration-v4.md

* Invoke webpack-dev-server using `webpack serve` instead:
"Error: Cannot find module 'webpack-cli/bin/config-yargs' when use v5"
webpack/webpack-dev-server#2424

* Pass production/development env with `--node-env` or nothing instead:
https://github.com/webpack/webpack-cli/blob/master/CHANGELOG.md#450-2021-02-02
    * `cross-env` is no longer needed
    * Webpack sets production/development env to 'production' by default
      https://v4.webpack.js.org/configuration/mode/
IepIweidieng added a commit to ccns/PttChrome that referenced this issue Dec 14, 2021
webpack-cli@4 requires webpack-dev-server@4:
https://github.com/webpack/webpack-dev-server/releases/tag/v4.0.0-beta.0

* Migrate config from v3 to v4:
https://github.com/webpack/webpack-dev-server/blob/master/migration-v4.md

* Invoke webpack-dev-server using `webpack serve` instead:
"Error: Cannot find module 'webpack-cli/bin/config-yargs' when use v5"
webpack/webpack-dev-server#2424

* Pass production/development env with `--node-env` or nothing instead:
https://github.com/webpack/webpack-cli/blob/master/CHANGELOG.md#450-2021-02-02
    * `cross-env` is no longer needed
    * Webpack sets production/development env to 'production' by default
      https://v4.webpack.js.org/configuration/mode/
markus-perl added a commit to markus-perl/administration that referenced this issue May 23, 2022
…ig-yargs'

Can't run make watch-admin in Dockware as it stops with the following error:

Error: Cannot find module 'webpack-cli/bin/config-yargs'
Require stack:
- /var/www/html/vendor/shopware/administration/Resources/app/administration/node_modules/webpack-dev-server/bin/webpack-dev-server.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/var/www/html/vendor/shopware/administration/Resources/app/administration/node_modules/webpack-dev-server/bin/webpack-dev-server.js:65:1)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/var/www/html/vendor/shopware/administration/Resources/app/administration/node_modules/webpack-dev-server/bin/webpack-dev-server.js'
  ]
}
makefile:65: recipe for target 'watch-admin' failed
make: *** [watch-admin] Error 1

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

If you're using webpack 4 you should use "webpack serve" instead of "webpack-dev-server":
https://stackoverflow.com/questions/64803892/error-error-cannot-find-module-webpack-cli-bin-config-yargs-require-stack
webpack/webpack-dev-server#2424
@alexander-akait alexander-akait unpinned this issue Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests