nodejs hello world示例 - 符号查找错误

时间:2012-04-28 01:32:40

标签: javascript linux node.js

更新 - LINUX FEDORA 15

以下示例:

http://simonwillison.net/2009/Nov/23/node/

我的代码:

var util = require('util'),
    http = require('http');

http.createServer(function(req, res) {
  res.sendHeader(200, {'Content-Type': 'text/html' });
  res.sendBody('<h1>Hello World</h1>');
  res.finish();
}).listen(8080);

util.puts('Server running at http://127.0.0.1:8080');

产生以下错误:

[abu@Beelzebub node_projects]$ nodejs helloworld.js
Server running at http://127.0.0.1:8080
nodejs: symbol lookup error: nodejs: undefined symbol: _ZN2v82V816IdleNotificationEv

3 个答案:

答案 0 :(得分:0)

要执行node.js应用程序,请使用node而不是nodejs调用它。

node helloworld.js

特定错误似乎与Node 0.6.15中的V8构建不匹配问题类似。您是否尝试过使用较新的(或回滚到旧版本)Node?

答案 1 :(得分:0)

在Fedora Linux上执行node.js安装下载并安装独立的rpm(http://nodejs.tchol.org/stable/f16/SRPMS/repoview/nodejs.html)并执行安装如下:

  1. 使用包管理器删除任何现有节点和nodejs应用程序

  2. 从独立rpm安装node.js

    rpm -ivh 。/配置 使 make install

  3. 尝试使用程序包管理器可能会导致依赖性问题,如以下站点所述:

    http://nodejs.tchol.org/

答案 2 :(得分:0)

这是2009年的教程和老api。你应该这样做

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

你的教程很旧:)切换到这个 - &gt;

http://howtonode.org/hello-node