Cannot create webpack.config.js via webpack-cli

Viewed 243

I cannot create webpack.config.js via webpack-cli.

I created package.json file using command yarn init

Then I installed webpack with command yarn add webpack webpack-cli @webpack-cli/init webpack-dev-server --dev Package.json file now looks like this:

{
    "name": "app",
    "version": "1.0.0",
    "main": "index.js",
    "license": "MIT",
    "devDependencies": {
        "@webpack-cli/init": "^1.1.3",
        "webpack": "^5.33.2",
        "webpack-cli": "^4.6.0",
        "webpack-dev-server": "^3.11.2"
    }
}

Now I try to initialize webpack.conf.js file with command yarn webpack-cli init but the result is:

yarn run v1.22.5  
$ /app/node_modules/.bin/webpack-cli init  
[webpack-cli] No commands found to run  
error Command failed with exit code 2.  
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The command init is not available:

root@7ea38e0fbec1:/app# yarn webpack --help  
yarn run v1.22.5  
$ /app/node_modules/.bin/webpack --help  
Usage: webpack [entries...] [options]  
Alternative usage to run commands: webpack [command] [options]    
The build tool for modern web applications.    
Commands:  
  build|bundle|b [entries...] [options]  Run webpack (default command, can be omitted).  
  configtest|t [config-path]             Validate a webpack configuration.  
  help|h [command] [option]              Display help for commands and options.  
  info|i [options]                       Outputs information about your system.  
  loader|l [output-path]                 Scaffold a loader.  
  plugin|p [output-path]                 Scaffold a plugin.  
  serve|s [entries...] [options]         Run the webpack dev server.  
  version|v [commands...]                Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.  
  watch|w [entries...] [options]         Run webpack and watch for files changes.    
To see list of all supported commands and options run 'webpack --help=verbose'.    
Webpack documentation: https://webpack.js.org/.  
CLI documentation: https://webpack.js.org/api/cli/.  
Made with ♥ by the webpack team.  
Done in 0.91s.  

What am I doing wrong? Previously it worked on the same docker image (node:15.3.0-buster)

0 Answers
Related