由於某些原因,它無法加載我的index.html中引用的index.js腳本。 server.js,index.html和index.js都位於我的項目文件夾的根目錄下。Express.js index.js 404(Not Found)
server.js
var express = require('express'),
app = express();
app.set("view options", {layout: false});
app.use(express.static(__dirname + '/public'));
app.set('views', __dirname + '/');
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');
app.get('/', function (req, res) {
res.render('index.html');
});
app.listen(4000, function() {
console.log('Example app listening on port 4000!');
});
的index.html
<html>
</head></head>
<body>
<div class="ink-grid vertical-space">
<div id="content">
<div class="panel vertical-space">
<div id="app"/>
</div>
</div>
</div>
<script type="text/babel" src="index.js"></script>
</body>
</html>
上呈現HTML中使用res.render(「指數」, { 信息:」」}); –