启动node.js服务器

tes*_*est 23 javascript node.js

我最近进入了节点,并将其安装在我的localhost上.我正在使用WAMP.我在Windows Vista上.

Anwyay,我安装了它.我在我的localhost目录中创建了一个新文件,并调用了该文件server.js

var http = require('http');

http.createServer(function (request, response) {
    response.writeHead(200, {
        'Content-Type': 'text/plain',
        'Access-Control-Allow-Origin' : '*'
    });
    response.end('Hello World\n');
}).listen(1337);
Run Code Online (Sandbox Code Playgroud)

然后我去了节点并尝试打字% node server.js,我得到的只是一个省略号.是什么赋予了?


更新:我检查了我的Systems变量,发现我PATH将node.js列为C:\Program Files (x86)\nodejs\

在此输入图像描述

dwe*_*ner 47

运行cmd然后运行node server.js.在您的示例中,您尝试使用REPL来运行命令,这不起作用.省略号是node.js,在关闭当前范围之前需要更多令牌(您可以在此处输入代码并在此处运行)

  • `错误:无法在Function.Module._load(module.js:289:25)的Function.Module._resolveFilename(module.js:338:15)找到模块'C:\ Program Files \nodejs\server.js'函数.Module.runMain(module.js:467:10)在启动时(node.js:136:18)在node.js:963:3` (3认同)