TerribleDeveloper
TerribleDeveloper

Reputation: 583

ReactJS: webpack Bundle.js not found(404)

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

Upvotes: 2

Views: 3030

Answers (3)

TerribleDeveloper
TerribleDeveloper

Reputation: 583

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

Upvotes: 1

Upasana
Upasana

Reputation: 1975

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.

Upvotes: 0

Rishabh Mishra
Rishabh Mishra

Reputation: 508

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

Upvotes: 0

Related Questions