2011-04-16 52 views
1

我是node.js的新手。我遵循Here的下載和安裝說明。運行node.js時出現問題

現在的問題是,當我嘗試這在我的終端

​​

我獲得以下消息

No script was specified. 
Usage: node [options] script.js [arguments] 
Options: 
    -v, --version  print node's version 
    --debug[=port]  enable remote debugging via given TCP port 
        without stopping the execution 
    --debug-brk[=port] as above, but break in script.js and 
        wait for remote debugger to connect 
    --v8-options  print v8 command line options 
    --vars    print various compiled-in variables 

Enviromental variables: 
NODE_PATH   ':'-separated list of directories 
        prefixed to the module search path, 
        require.paths. 
NODE_DEBUG   Print additional debugging output. 

Documentation can be found at http://nodejs.org/api.html or with 'man node' 

之後,我試過了這個例子:

var http = require('http'); 
http.createServer(function (req, res) { 
    res.writeHead(200, {'Content-Type': 'text/plain'}); 
    res.end('Hello World\n'); 
}).listen(8124, "127.0.0.1"); 
console.log('Server running at http://127.0.0.1:8124/'); 

它說:引發ReferenceError :控制檯未定義。

我GOOGLE了這一點,並發現我還沒有安裝正確的NodeJS,所以我又安裝了它,但沒有成功:(

請幫助!

+0

如果你輸入'node --version',你會得到什麼? – yojimbo87 2011-04-16 08:06:11

回答

3

安裝手冊版本太舊。

做到這一點

wget http://nodejs.org/dist/node-v0.4.6.tar.gz 
gunzip node-v0.4.6.tar.gz 
tar -xf node-v0.4.6.tar 
cd node 
./configure 
make 
sudo make install 

順便說一句,這裏是官方的安裝說明:https://github.com/joyent/node/wiki/Installation

+0

謝謝......它正在運行:) – Dharmesh 2011-04-16 08:31:12

+0

@Dharmesh歡迎;) – 2011-04-16 08:34:57

相關問題