React App suddenly stopped working; TypeError: Cannot read properties of undefined (reading 'prototype')

React App suddenly stopped working; TypeError: Cannot read properties of undefined (reading 'prototype')

我没有对我的应用程序进行任何重大更改,并且 运行 很好,直到我开始收到此错误

TypeError: Cannot read properties of undefined (reading 'prototype')

(anonymous function)
.../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.

我已尝试还原对代码所做的任何更改,并再次删除了 node_modules 和 运行 npm install,但错误仍然存​​在

这里的上下文太少,无法自信地猜测可能是什么问题。

你能验证这个错误发生在哪里吗?是浏览器错误,还是节点进程错误?看起来错误发生在客户端的 node_modules 中。您的客户是快递服务器吗?

我唯一能破译的是 http 模块可能在您需要 express 响应的代码的地方丢失了。

人们遇到这类错误时似乎遇到的一个问题是他们的 IDE 不小心从 express

自动导入了响应
import { response } from 'express'

当他们在 UI

中编写响应处理程序时
.then((response) => ...)

您可以尝试搜索您的应用程序并确保您没有在文件中进行此类导入,这些文件最终会出现在浏览器中。