gpt4 book ai didi

node.js - 类型错误 : Cannot read property 'prototype' of undefined React Express

转载 作者:太空宇宙 更新时间:2023-11-03 23:49:41 24 4
gpt4 key购买 nike

我有一个项目使用 Express 和 React,一切正常,

我没有对代码进行任何更改,突然它开始出现此错误。

前几天,我已经将node从10.15.0升级到12.x,并添加了axios。

我在这些更改之后进行了测试,它有效。现在不行了,这是什么意思??


TypeError: Cannot read property 'prototype' of undefined
(anonymous function)
C:/Desktop/ahmad/client/node_modules/express/lib/response.js:42
39 | * @public
40 | */
41 |
> 42 | var res = Object.create(http.ServerResponse.prototype)
43 |
44 | /**
45 | * Module exports.
*/

View compiled
./node_modules/express/lib/response.js
http://localhost:3000/static/js/bundle.js:28181:30
__webpack_require__
C:/.../ahmad/client/webpack/bootstrap 4501180ca3adc0d915c0:678
675 | };
676 |
677 | // Execute the module function
> 678 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
679 |
680 | // Flag the module as loaded
681 | module.l = true;
View compiled
fn
C:/.../ahmad/client/webpack/bootstrap 4501180ca3adc0d915c0:88
85 | console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId);
86 | hotCurrentParents = [];
87 | }
> 88 | return __webpack_require__(request);
89 | };
90 | var ObjectFactory = function ObjectFactory(name) {
91 | return {
View compiled
./node_modules/express/lib/express.js
C:/.../Desktop/ahmad/client/node_modules/express/lib/express.js:22
19 | var Route = require('./router/route');
20 | var Router = require('./router');
21 | var req = require('./request');
> 22 | var res = require('./response');
23 |
24 | /**
25 | * Expose `createApplication()`.
*/
View compiled
__webpack_require__
C:/.../Desktop/ahmad/client/webpack/bootstrap 4501180ca3adc0d915c0:678
675 | };
676 |
677 | // Execute the module function
> 678 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
679 |
680 | // Flag the module as loaded
681 | module.l = true;
View compiled
fn
C:/.../Desktop/ahmad/client/webpack/bootstrap 4501180ca3adc0d915c0:88
85 | console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId);
86 | hotCurrentParents = [];
87 | }
> 88 | return __webpack_require__(request);
89 | };
90 | var ObjectFactory = function ObjectFactory(name) {
91 | return {
View compiled

最佳答案

我发现我输入错误

从 { 'express' } 导入响应

我发现当您尝试在前端调用后端内容时会发生此问题。当我删除该行时,问题解决了。

编辑:原来我没有输入 import 语句,因为我使用了 response 这个词作为变量名,它是自动导入的。我不确定导入是来自 React 本身还是另一个 VS code 自动完成扩展。

关于node.js - 类型错误 : Cannot read property 'prototype' of undefined React Express,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59903475/

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