gpt4 book ai didi

node.js - node.js 中的 process.nextTick 错误?

转载 作者:搜寻专家 更新时间:2023-10-31 22:36:50 25 4
gpt4 key购买 nike

enter image description here

我在这个非常基本的 node.js 示例中遇到 process.nextTick 错误。

请问有没有大佬解一下? Node 是否无法开始监听端口 8000?

# cat nodejs.js
net = require("net");
s = net.createServer();

net.on('connection', function (c) {
c.end('hello');
});

s.listen(8000);

# node nodejs.js

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Object #<Object> has no method 'on'
at Object.<anonymous> (/home/ec2-user/praveen/nodejs.js:4:5)
at Module._compile (module.js:432:26)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Array.0 (module.js:470:10)
at EventEmitter._tickCallback (node.js:192:40)

最佳答案

这是 Ryan 幻灯片中的错字! :-0

s/net.on/s.on/

关于node.js - node.js 中的 process.nextTick 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8673775/

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