我写的
hello.js var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Node.jsn');
}).listen(8124, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8124/');运行 node hello.js 结果显示: ReferenceError:hello is not defined at repl:1:2 at ... ...
hello.js var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Node.jsn');
}).listen(8124, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8124/');运行 node hello.js 结果显示: ReferenceError:hello is not defined at repl:1:2 at ... ...
hello.js的路径对不对
throw e; // process.nextTick error, or 'error' event on first tick
^
ReferenceError: hello is not defined
at Object.<anonymous> (/home/Wang/node-v0.4.0/hello.js:1:63)
at Module._compile (module.js:373:26)
at Object..js (module.js:379:10)
at Module.load (module.js:305:31)
at Function._load (module.js:271:10)
at Array.<anonymous> (module.js:392:10)
at EventEmitter._tickCallback (node.js:108:26)
这是我用cygwin安装的,路径/home/Wang/node-v0.4.0/hello.js。这是何故啊?
先尝试用node.exe 跑跑js服务器再想想现在的情况吧... 明显是hello.js找不到
比如,c:\新建文件件\hello.js 这样不行 c:\abc\hello.js 这样可以。