gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-11-01 00:09:09 24 4
gpt4 key购买 nike

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

最佳答案

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

关于javascript - nodejs hello world 示例 - 符号查找错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10359820/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com