Search code examples
javascriptwebpackwebpack-2

Webpack can't find webpack.config.js


Webpack 2.2.0 is giving me this error when I try to run an npm script:

No configuration file found and no output filename configured via CLI option.

I've made sure that webpack.config.js is in the src folder.

module.exports = {
entry: './src/app.js',
output: {
    filename: './dist/app.bundle.js'
   }
}

enter image description here

Here is my project structure.

I appreciate any assistance.


Solution

  • You have 2 solutions:

    • move webpack.config.js to the root folder instead of ./src (pointed out by Jared Farrish)
    • use the --config attribute with the CLI that points to ./src/webpack.config.js: webpack --config src/webpack.config.js