你好的NodeJS世界的例子 - 符号查找错误(nodejs hello world example

2019-09-16 19:43发布

UPDATE - 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

Answer 1:

这是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



Answer 2:

要执行的Node.js应用程序,使用节点,而不是打电话的NodeJS它。

node helloworld.js

具体的错误似乎类似于V8构建不匹配的问题,这是在节点0.6.15。 你是否尝试过使用较新的(或回滚到旧)节点的版本?



Answer 3:

在Fedora Linux系统下载执行的node.js安装和安装独立的RPM(http://nodejs.tchol.org/stable/f16/SRPMS/repoview/nodejs.html)并进行安装,如下所示:

  1. 删除所有现有节点和应用程序的NodeJS使用包管理器

  2. 安装从独立的转速的node.js

    RPM -ivh的./configure使make install的

尝试使用的软件包管理器可能会导致作为在以下网站所描述的依赖问题:

http://nodejs.tchol.org/



文章来源: nodejs hello world example - symbol lookup error