2

我对 Node.js 很陌生,我在 Node.js 中运行一个简单的“hello world”程序时遇到了问题

程序1:

console.log("hello world");

程序2:

var http = require('http');

http.createServer(function (request, response) {
    response.writeHead(200, {'Content-Type': 'text/plain'});
    response.end('Hello World\n');
}).listen(8124);

console.log('Server running at http://127.0.0.1:8124/');

运行这两个程序后,终端继续看起来是这样的:

>node hello.js
...
4

1 回答 1

4

您在 node js 命令提示符中编写了以下命令

节点你好.js

您在终端中得到了点 (....),因为您没有提供 hello.js 文件的完整路径。

试试这个,例如假设你的 hello.js 文件的路径是 C:\files\hello.js

所以,

节点 C:\files\hello.js

这将为您的程序 1 显示正确的“Hello world”消息。这可能会解决您的问题。

问候

于 2013-11-06T10:46:10.127 回答