运行node.js时出现问题

时间:2011-04-16 08:00:21

标签: javascript node.js

我是node.js的新手。我按照Here的下载和安装说明进行操作。

现在问题出现在我的终端

  

节点

我收到以下消息

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所以我再次安装它但没有成功:(

请帮助!!

1 个答案:

答案 0 :(得分: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

BTW,这是官方安装说明:https://github.com/joyent/node/wiki/Installation