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/bin/config-yargs' #27

Closed
nurbek-ab opened this issue Mar 19, 2018 · 39 comments
Closed

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

nurbek-ab opened this issue Mar 19, 2018 · 39 comments

Comments

@nurbek-ab
Copy link

I'am using webpack 4 and when trying to run my tests with this package I get the following error:

> cross-env NODE_ENV=test jest-webpack

module.js:540
    throw err;
    ^

Error: Cannot find module 'webpack/bin/config-yargs'
    at Function.Module._resolveFilename (module.js:538:15)
    at Function.Module._load (module.js:468:25)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at run (C:\Users\Me\Projects\MyProject\node_modules\jest-webpack\jest-webpack.js:24:5)
    at Object.<anonymous> (C:\Users\Me\Projects\MyProject\node_modules\jest-webpack\jest-webpack.js:69:3)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
npm ERR! Test failed.  See above for more details.
@nurbek-ab
Copy link
Author

nurbek-ab commented Mar 19, 2018

My package.json:

{
  ...
  "scripts": {
    "start": "cross-env NODE_ENV=development webpack-dev-server --debug --watch --config webpack.dev.js",
    "build": "cross-env NODE_ENV=production webpack -p --config webpack.prod.js",
    "test": "cross-env NODE_ENV=test jest-webpack --verbose --no-cache"
  },
  "devDependencies": {
    ...
    "jest": "^22.4.2",
    "jest-webpack": "^0.4.0",
    "webpack": "^4.1.1",
    "webpack-cli": "^2.0.12",
    "webpack-dev-server": "^3.1.1",
    "webpack-merge": "^4.1.2"
  }
}

@therise3107
Copy link

I'm also facing the same issue

@chvid
Copy link

chvid commented Mar 26, 2018

I don't webpack 4 is supported at present. In webpack 4 config-yargs sits inside webpack-cli.

@zz-james
Copy link

wtf? how do I fix this?

@ssthil
Copy link

ssthil commented May 15, 2018

I had faced the same issue since I am using webpack 4.8.3 then I have been installed yarn add -D webpack-cli and works perfectly.

my package.json: FYR

"devDependencies": {
"webpack": "^4.8.3",
"webpack-cli": "^2.1.3",
"webpack-dev-server": "^3.1.4"
}

@tchakabam
Copy link

tchakabam commented May 15, 2018

I had this issue as I had webpack-dev-server v2.x installed against webpack v4.

now, updated to dev-server v3 and it works.

    "webpack": "^4.8.3",
    "webpack-cli": "^2.1.3",
    "webpack-dev-server": "^3.1.4",

@quinn
Copy link

quinn commented Jun 7, 2018

I am also having this issue, and i have webpack-cli installed. this issue makes sense, since webpack/bin/config-yargs has been moved to webpack-cli/bin/config-yargs.

@ajchandrawat
Copy link

C:\rjs>npm run start

rjs@1.0.0 start C:\rjs
webpack-dev-server --hot

× 「wds」: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.

  • configuration.module has an unknown property 'loaders'. These properties are valid:
    object { exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, noParse?, rules?, defaultRules?, unknownContextCritical?, unknownContextRecursive?, unknownContextRegExp?, unknownContextRequest?, unsafeCache?, wrappedContextCritical?, wrappedContextRecursive?, wrappedContextRegExp?, strictExportPresence?, strictThisContextOnImports? }
    -> Options affecting the normal modules (NormalModuleFactory).
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! rjs@1.0.0 start: webpack-dev-server --hot
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the rjs@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\User\AppData\Roaming\npm-cache_logs\2018-06-08T07_01_09_959Z-debug.log

I am facing this issue, help me out

@nurbek-ab
Copy link
Author

@ajchandrawat your issue is not related to this topic.

@brien-givens
Copy link

brien-givens commented Jun 13, 2018

I also have this issue - I have webpack, webpack-cli, and webpack-dev-server all installed and up to date:

    "webpack": "^4.12.0",
    "webpack-cli": "^3.0.6",
    "webpack-dev-server": "^3.1.4"

error:

> jest-webpack

internal/modules/cjs/loader.js:596
    throw err;
    ^

Error: Cannot find module 'webpack/bin/config-yargs'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
    at Function.Module._load (internal/modules/cjs/loader.js:520:25)
    at Module.require (internal/modules/cjs/loader.js:650:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at run (/Users/brien/stockup/stark/node_modules/jest-webpack/jest-webpack.js:24:5)
    at Object.<anonymous> (/Users/brien/stockup/stark/node_modules/jest-webpack/jest-webpack.js:69:3)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)

@quinn
Copy link

quinn commented Jun 14, 2018

this package is not compatible with the latest stable release of webpack.

@harvey56
Copy link

@quinn : can you elaborate ? I have the same issue as OP and as @brien-givens. From what I understand, installing webpack-cli solves the issue in many cases, however I have it installed.

I have the latest versions installed as of today :
"webpack": "^4.13.0", "webpack-cli": "^3.0.8", "webpack-dev-server": "^3.1.4"

@xubeng
Copy link

xubeng commented Jun 30, 2018

@harvey56 I have the same problem as you, I have not fixed it.

@msajjad650
Copy link

@tchakabam Thank I solved the issue

@raybon-lee
Copy link

@tchakabam very nice!

@quanzhiyuan
Copy link

mark

@yury-kozlov
Copy link

updating webpack-dev-server helped. thanks!

@brandonparis
Copy link

I'm still having issues with this, have tried all of the above.

in devDependencies:

    "webpack": "^4.5.0",
    "webpack-cli": "3.3.1",
    "webpack-dev-server": "^3.3.1"

Every time I try to run webpack-dev-server --config webpack.dev.config.js I get the same error:

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:20:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/webpack-dev-server/bin/webpack-dev-server.js:86: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)

At a loss, can anybody help?

@0x53A
Copy link

0x53A commented May 6, 2019

@Brandonprs

I had the same error message with webpack-dev-server@3.1.10 and webpack-cli@3.3.2.

Downgrading webpack-cli to 3.3.0 helped me.

@Aid19801
Copy link

Why is this issue closed? Is there a solution now?

@quinn
Copy link

quinn commented May 22, 2019

@Aid19801 seems that way: #29

@brandonparis
Copy link

@0x53A It actually had turned out to be something weird where I had started using yarn instead of npm and the yarn.lock was throwing everything awry. Removing all references to yarn and doing a full rm -rf node_modules/ package-lock.json seemed to solve the issue

@dimun
Copy link

dimun commented May 22, 2019

My current solution was to upgrade to:
"webpack-dev-server": "3.4.1"

@ashishnitinpatil
Copy link

Following versioning worked for me:

"webpack": "4.35.0",
"webpack-cli": "3.3.5",
"webpack-dev-server": "3.7.2",

@forrestblade
Copy link

I cannot find a solution for this. here is my dev dependencies
code

@jackrobertscott
Copy link

I am also getting this issue with the latest versions of all packages:

{
  "devDependencies": {
    "webpack": "^4.35.2",
    "webpack-cli": "^3.3.5",
    "webpack-dev-server": "^3.7.2"
  },
}

This is the error which is returned:

yarn run v1.13.0
$ webpack-dev-server
The CLI moved into a separate package: webpack-cli
Please install 'webpack-cli' in addition to webpack itself to use the CLI
-> When using npm: npm i -D webpack-cli
-> When using yarn: yarn add -D webpack-cli
internal/modules/cjs/loader.js:615
    throw err;
    ^

Error: Cannot find module 'webpack-cli/bin/config-yargs'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:613:15)
    at Function.Module._load (internal/modules/cjs/loader.js:539:25)
    at Module.require (internal/modules/cjs/loader.js:667:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/Users/jackscott/Documents/workspace/widgets/node_modules/webpack-dev-server/bin/webpack-dev-server.js:60:1)
    at Module._compile (internal/modules/cjs/loader.js:738:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:749:10)
    at Module.load (internal/modules/cjs/loader.js:630:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
    at Function.Module._load (internal/modules/cjs/loader.js:562:3)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@jackrobertscott
Copy link

My solution was to remove hoisting from my yarn workspace i.e. in my root package.json

{
  "workspaces": {
    "packages": ["packages/*"],
    "nohoist": ["**"]
  }
}

@xeontem
Copy link

xeontem commented Jul 25, 2019

had the same issue. Updating dev-server solved it.

@xuya227939
Copy link

Updating webpack-dev-server@3.4.1 thanks!

@cmaliwal
Copy link

cmaliwal commented Nov 7, 2019

I am also facing the same issue.

internal/modules/cjs/loader.js:605
    throw err;
    ^

Error: Cannot find module 'yargs'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
    at Function.Module._load (internal/modules/cjs/loader.js:529:25)
    at Module.require (internal/modules/cjs/loader.js:657:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/usr/lib/nodejs/webpack/bin/webpack.js:16:13)
    at Module._compile (internal/modules/cjs/loader.js:721:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:774:12)
    at executeUserCode (internal/bootstrap/node.js:499:15)
    at startMainThreadExecution (internal/bootstrap/node.js:436:3)

My dependencies:

"webpack": "^4.41.2",
 "webpack-cli": "^3.3.10",
 "webpack-dev-server": "^3.9.0"

Expecting stable solution. :)

@saurabhkanswal
Copy link

I am also facing the same issue.

internal/modules/cjs/loader.js:605
    throw err;
    ^

Error: Cannot find module 'yargs'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
    at Function.Module._load (internal/modules/cjs/loader.js:529:25)
    at Module.require (internal/modules/cjs/loader.js:657:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/usr/lib/nodejs/webpack/bin/webpack.js:16:13)
    at Module._compile (internal/modules/cjs/loader.js:721:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:774:12)
    at executeUserCode (internal/bootstrap/node.js:499:15)
    at startMainThreadExecution (internal/bootstrap/node.js:436:3)

My dependencies:

"webpack": "^4.41.2",
 "webpack-cli": "^3.3.10",
 "webpack-dev-server": "^3.9.0"

Expecting stable solution. :)

@cmaliwal any update issue?

@vanderlin
Copy link

vanderlin commented Nov 19, 2019

This works for me

"webpack": "^4.8.3",
"webpack-cli": "3.3.0",
"webpack-dev-server": "^3.1.4"

@tsungjung411
Copy link

I am also having this issue, and i have webpack-cli installed. this issue makes sense, since webpack/bin/config-yargs has been moved to webpack-cli/bin/config-yargs.

According to your comment, I solved this by:
(1) $ npm install webpack-cli
(2) modify package.json
Before: "webpack-dev-server": "^2.9.1"
After: "webpack-dev-server": "^3.9.0"
(3) update package.json
$ npm install

And it worked for me.

@mahinourrelsheikh
Copy link

After npm install webpack-cli and changing your dependencies in package.json , you should delete your package-lock.json file then do npm install again

@alfrededison
Copy link

with latest jest-webpack and webpack-cli, I used this configuration to run

"jest": "^23.1.0",
"jest-webpack": "^0.5.1",
"webpack-cli": "~3.0.0",

Since webpack-cli changed its folder structure for later version

@VivekkChudasama
Copy link

I'm also facing the same issue

@suplakite
Copy link

https://medium.com/@cyishere/error-cannot-find-module-webpack-cli-bin-config-yargs-6d704533062a

Versions from this article helped me fix the problem

@jcole099
Copy link

@suplakite Thanks a bunch! That worked for me.

I used the following versions to make webpack dev server work:
webpack 4.32.2
webpack-cli 3.3.2
webpack-dev-server 3.5.1

@vinaymcscet
Copy link

My package.json is this -
{
"name": "webpack-course",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1",
"dev": "webpack serve"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@webpack-cli/init": "^1.1.3",
"webpack-dev-server": "^3.11.2"
},
"devDependencies": {
"webpack": "^5.37.1",
"webpack-cli": "^4.7.0"
}
}

But still getting the same issue.

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