nodeJs文件中的语法错误运行

当我尝试运行具有以下内容的第一个js文件时,我对nodejs非常陌生

var http = require("http"); http.createServer(function (request, response) { response.writeHead(200, {'Content-Type': 'text/plain'}); response.end('Hello World\n'); }).listen(8081); console.log('Server running at http://127.0.0.1:8081/'); 

与命令

$ node fullpath / filename.js

我收到如下所示的错误 错误信息

任何人都可以告诉什么是错的。 我正在使用nodejs appliction窗口

请不要在REPL运行代码

 [user@machine]$node > node app.js SyntaxError: Unexpected identifier at Object.exports.createScript (vm.js:24:10) at REPLServer.defaultEval (repl.js:225:25) at bound (domain.js:287:14) at REPLServer.runBound [as eval] (domain.js:300:12) at REPLServer.<anonymous> (repl.js:417:12) at emitOne (events.js:82:20) at REPLServer.emit (events.js:169:7) at REPLServer.Interface._onLine (readline.js:210:10) at REPLServer.Interface._line (readline.js:549:8) at REPLServer.Interface._ttyWrite (readline.js:826:14) 

只需在命令行中运行它

 [user@machine]$node app.js Server running at http://127.0.0.1:8081/