2

I have set up a simple react project. I am using a webpack, I am geting an error GET http://localhost:3001/bundle.js 404 (Not Found) however bundle.js is generated in public folder

here is my package.json file

`{ "name": "hello-react", "version": "1.0.0", "description": "simple react app", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "MIT", "dependencies": { "express": "^4.13.4", "react": "^0.14.7", "react-dom": "^0.14.7" }, "devDependencies": { "babel-core": "^6.5.1", "babel-loader": "^6.2.2", "babel-preset-es2015": "^6.5.0", "babel-preset-react": "^6.5.0", "webpack": "^1.12.13" } }` 

here is server.js

var express = require('express'); // Create our app var app = express(); app.use(express.static('public')); app.listen(3001,function(){ console.log('server is up on 3001'); }); 

index.html

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"/> </head> <body> <div id="app"></div> <script src="bundle.js"></script> </body> </html> 

my folder structure enter image description here

3 Answers 3

1

Thanks All of you guys. I resolved issue, the problem was with runing a webpack command and then runing a server.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank You ! It worked for me. After running npm run build and after that running my server resolved the issue.
0

because you have bundle,js in public folder, check the name again

2 Comments

you used the comma instead(,) of dot(.)
Thanks, Rishabh, It wasn't comma however it appears to be
0

According to your folder structure, your 'bundle,js' contains comma (,) this should be dot(.) change your bundle.js name in your index.html if its wrong there. Or, go to your webpack-config file and check for 'output' file name, there must be some error. or, if you are creating it dynamically then change it there.

1 Comment

Thanks, Upasana, It wasn't comma however it appears to be

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.