1
大学のサーバにubuntuインスタンスを作成しました。 NodeJSとNPMをインストールし、FTP接続でファイルを送信できます。NodeJS - SyntaxError:予期しないトークンILLEGAL
次のNodeJS Webサーバーファイルを私のintanceに送信し、インスタンスip-adressで実行したいとします。
var http = require(“http“);
http.createServer(function(request, response) {
response.writeHead(200, {‚content-type’: ‚text/plain‚});
response.write(‘Hello World’);
response.end;
}).listen(3000‚141.28.107.7);
console.log(“server is running“);
私は
sudo nodejs server.js
私は、次のエラーメッセージが出ていてこのファイルを実行すると:
sudo: unable to resolve host nodejs
/home/robin/files/webserver.js:1
(function (exports, require, module, __filename, __dirname) { var http = require(“http“);
^
SyntaxError: Unexpected token ILLEGAL
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:148:18)
at node.js:405:3
私のエラーは推論にありますか? ありがとう!
引用符で囲まれた野生の推測ホスト名 '.listen(3000、" 141.28.107.7 ");' –