我建立了一個簡單的反應項目。我使用的是的WebPack,我歌廳錯誤GET http://localhost:3001/bundle.js 404(未找到),但是bundle.js公用文件夾ReactJS:webpack Bundle.js找不到(404)
在這裏生成是我的package.json文件
`{
"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"
}
}`
這裏是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>
肯定的,但/公衆是你用逗號,而不是主目錄 –
('')點('.') –
謝謝,RISHABH,這不是逗號但它似乎是 –