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 · 16 comments

Comments

Projects
None yet
@nurbek-ab

nurbek-ab commented Mar 19, 2018

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

This comment has been minimized.

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

This comment has been minimized.

therise3107 commented Mar 19, 2018

I'm also facing the same issue

@chvid

This comment has been minimized.

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

This comment has been minimized.

zz-james commented May 14, 2018

wtf? how do I fix this?

@ssthil

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

ajchandrawat commented Jun 8, 2018

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

This comment has been minimized.

nurbek-ab commented Jun 8, 2018

@ajchandrawat your issue is not related to this topic.

@brien-givens

This comment has been minimized.

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

This comment has been minimized.

quinn commented Jun 14, 2018

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

@harvey56

This comment has been minimized.

harvey56 commented Jun 29, 2018

@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

This comment has been minimized.

xubeng commented Jun 30, 2018

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

@msajjad650

This comment has been minimized.

msajjad650 commented Aug 24, 2018

@tchakabam Thank I solved the issue

@pengleelove

This comment has been minimized.

pengleelove commented Sep 11, 2018

@tchakabam very nice!

@quanzhiyuan

This comment has been minimized.

quanzhiyuan commented Oct 30, 2018

mark

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment