gpt4 book ai didi

javascript - NodeJS-类型错误 : Busboy is not a constructor

转载 作者:行者123 更新时间:2023-12-05 02:34:26 24 4
gpt4 key购买 nike

所以,几天前发生了一些事情,我的一个项目开始显示以下错误:

TypeError: Busboy is not a constructor
at /app/node_modules/connect-busboy/index.js:21:18
at /app/node_modules/express-fileupload/lib/index.js:9:31
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/app/node_modules/express/lib/router/index.js:323:13)
at /app/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/app/node_modules/express/lib/router/index.js:341:12)
at next (/app/node_modules/express/lib/router/index.js:275:10)
at urlencodedParser (/app/node_modules/body-parser/lib/types/urlencoded.js:100:7)
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/app/node_modules/express/lib/router/index.js:323:13)
at /app/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/app/node_modules/express/lib/router/index.js:341:12)
at next (/app/node_modules/express/lib/router/index.js:275:10)
at jsonParser (/app/node_modules/body-parser/lib/types/json.js:119:7)
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/app/node_modules/express/lib/router/index.js:323:13)
at /app/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/app/node_modules/express/lib/router/index.js:341:12)
at next (/app/node_modules/express/lib/router/index.js:275:10)
at logger (/app/node_modules/morgan/index.js:144:5)
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/app/node_modules/express/lib/router/index.js:323:13)

我认为奇怪的是,这个 Busboy 没有在我的代码中使用,仅在 node_modules 的依赖项中使用。有谁知道 Busboy 的版本是否存在任何兼容性错误或错误中列出的任何可能导致此类问题的错误?

最佳答案

只是为可能感到困惑的人添加另一个答案。 Busboy 导出一个函数而不是一个类。因此,不需要使用 new 关键字来创建 Busboy 的实例。

const Busboy = require('busboy');
const busboy = Busboy({ headers: req.headers });

这个答案只是为了让那些对多个示例和教程感到困惑的人更加清晰。如果有任何改进,请提出建议。

关于javascript - NodeJS-类型错误 : Busboy is not a constructor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70769641/

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