【问题标题】:React App suddenly stopped working; TypeError: Cannot read properties of undefined (reading 'prototype')React App 突然停止工作; TypeError:无法读取未定义的属性(读取“原型”)
【发布时间】:2021-11-20 08:02:14
【问题描述】:

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

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 但错误仍然存​​在

【问题讨论】:

    标签: javascript reactjs express mern


    【解决方案1】:

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

    你能确认这个错误发生在哪里吗?是浏览器错误,还是节点进程中的错误?似乎错误发生在客户端的node_modules 中。你的客户是快递服务器吗?

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

    当涉及到这类错误时,人们似乎遇到的一个问题是他们的 IDE 意外地从 express 自动导入响应

    import { response } from 'express'
    

    当他们在 UI 中编写响应处理程序时

    .then((response) => ...)
    

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

    【讨论】:

    • 是的,有一个我没有注意到的随机快速导入
    猜你喜欢
    • 1970-01-01
    • 2021-10-31
    • 2020-05-11
    • 1970-01-01
    • 2021-08-01
    • 2022-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多