gpt4 book ai didi

node.js - TypeError : dest. 结束不是函数

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

我正在尝试使用 HTTP/2。我的 express 版本是 5.0.0-alpha.2, http2 版本为3.3.4。

我想 http2 应该 work well with express 5 .

const http2 = require('http2');
// const http2 = require('spdy'); // using spdy package here, everything works perfect

const options = {
key: fs.readFileSync(path.join(__dirname, 'private', 'server.key')),
cert: fs.readFileSync(path.join(__dirname, 'private', 'server.crt'))
};

const server = http2
.createServer(options, app)
.listen(3000, err => {
if (err) throw new Error(err);

// I can see "Listening..." message, which means the server starts running well.
console.log('Listening...');
});

服务器开始运行良好,但是当我打开客户端网站时,它在终端中给我这个错误:

_stream_readable.js:512
dest.end();
^

TypeError: dest.end is not a function
at Stream.onend (_stream_readable.js:512:10)
at Stream.g (events.js:286:16)
at emitNone (events.js:91:20)
at Stream.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:975:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)

最佳答案

好像node-http2 Express 尚未支持。请跟踪此问题Support for module http在 github 上。

与此同时,您可以留在node-spdy .

const spdy = require('spdy');

const options = {
key: fs.readFileSync(path.join(__dirname, 'private', 'server.key')),
cert: fs.readFileSync(path.join(__dirname, 'private', 'server.crt'))
};

const server = spdy
.createServer(options, app)
.listen(3000, err => {
if (err) throw new Error(err);
console.log('Listening...');
});

关于node.js - TypeError : dest. 结束不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39150754/

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