我写的
 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 ... ...

解决方案 »

  1.   

    在什么环境下运行
    hello.js的路径对不对
      

  2.   

    错误很明白了已经   hello.js路径对不对
      

  3.   

    $ node hellonode.js:116
            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。这是何故啊?
      

  4.   

    ...  不要总想着安装了就没事了啊.  nodejs的编译是有路径限制的,路径不对就不行了.
    先尝试用node.exe 跑跑js服务器再想想现在的情况吧... 明显是hello.js找不到
      

  5.   

    用node.exe,然后运行路径不要带中文字符。
    比如,c:\新建文件件\hello.js 这样不行  c:\abc\hello.js 这样可以。