[Solved] [email protected] Error: Cannot find module ‘webpack/bin/config-yargs‘

1. Use [email protected] When I execute webpack dev server through script of package.json , I report the following error:

Error: Cannot find module 'webpack/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)
  ......

Reason: This is the current version [email protected] I won’t support it [email protected]

Solution: re install a webpack dev server, which is compatible with version 3.0 or above

1 npm i [email protected] -D

At this point, you can… If you still report an error, refer to the last one

2. Webpack cli must be installed for webpack4.0 or above. Otherwise, an error is reported as follows:

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 this time, you need to install webpack cli:

npm i  webpack-cli -D

3. In this way, an error may be reported after the installation. At this time, you need to uninstall all the webpack cli webpack dev servers

Re install together, be sure to remember, install together at the same time

npm i webpack webpack-cli webpack-dev-server -D

My installation is as follows:

Similar Posts: