我正在制作一个在线HTML5游戏,这些是我的代码。HTML5 Express Node.js - _dirname未定义
app.js
var express = require('express');
var app = express()
var serv = require('http').Server(app);
app.get('/',function(req, res) {
res.sendFile(_dirname + '/client/index.html');
});
app.use('/client', express.static(_dirname + '/client'));
serv.listen(2000);
的index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Game</title>
</head>
<body>
Hello world
</body>
</html>
当我在 '节点app.js' 控制台(在正确的目录,我已经选中)键入它给我的错误
ReferenceError: _dirname is not defined
at Object.<anonymous> (C:\Users\Amitai\Documents\AmitaiHP\app.js:8:35)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
请帮助,有人,请不要标记这个问题,因为你不能回答它(这发生了很多m e)
我是个白痴。谢谢。 –