Webpack: cannot find bundle.js

I finally got the dev server and I got something on the screen. I installed the "start" script for NPM as follows:

"start": "webpack-dev-server --content-base app" 

I get an error message:

 http://localhost:8080/bundle.js Failed to load resource: the server responded with a status of 404 (Not Found) 

My folders are installed as follows:

 appDir ->app ->node_modules webpack.config.js package.json 

My webpack.config.js:

 module.exports = { context: __dirname + '/app', entry: './index.js', output: { path: __dirname + '/app', filename: './bundle.js' } } 

Can you tell what happened?

+5
source share
1 answer

bundle.js is located inside your /app directory. This path option in the output indicates the absolute path that the file follows.

Also you do not need ./ in the file name. It will be resolved regarding output.path , but it is confusing and may affect your problem.

+7
source

All Articles