繁体   English   中英

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

[英]nodejs hello world example - symbol lookup error

更新 - 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

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

node helloworld.js

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

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

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

  2. 从独立rpm安装node.js.

    rpm -ivh ./configure make make install

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

http://nodejs.tchol.org/

这是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/");

你的教程很旧:)切换到这个 - >

http://howtonode.org/hello-node

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM