【问题标题】:Wallaby and prototype error小袋鼠和原型错误
【发布时间】:2018-01-04 22:01:30
【问题描述】:

问题是原型没有定义,尽管在节点控制台中编写 http.IncomingMessage.prototype 确实给出了一个对象作为输出。有什么想法吗?

var req = Object.create(http.IncomingMessage.prototype)


Uncaught TypeError: Cannot read property 'prototype' of undefined
at http://localhost:62625/____wallaby-bundle.js?1501265946287&wallabyFileId=bundle:219253

【问题讨论】:

  • 它无法读取原型属性,因为http.IncomingMessage 对象不存在。我认为在此之前某处有一个异步调用,最终http.IncomingMessage 将存在,但在你试图摆弄它的那一刻,它不存在。
  • 同意Will,Cannot read property 'prototype' of undefined表示http.IncomingMessage未定义。
  • 如何解决?
  • 您是否忘记了需要http 模块?

标签: javascript node.js angular typescript wallaby.js


【解决方案1】:

我认为http.IncomingMessage 未定义。

可能发生 http 已在您的代码中的某些位置被覆盖。

var http = require('http');
var req = Object.create(http.IncomingMessage.prototype)

我已经测试了上面的代码,它可以工作。

【讨论】:

  • 我有同样的问题:''' var http = __webpack_require__(968); var 新鲜 = __webpack_require__(958); var parseRange = __webpack_require__(961); var parse = __webpack_require__(905); var proxyaddr = __webpack_require__(964); /** * 请求原型。 * @public */ var req = Object.create(http.IncomingMessage.prototype
  • webpack 捆绑 id 为 968 的 http 模块。你能检查一下你的 webpack 包中是否包含 http 模块吗?
  • 这里是 bundle .js 文件。 http 模块似乎包含在内,但它仍然不起作用:( ufile.io/sot8h Line 235912
猜你喜欢
  • 1970-01-01
  • 2016-05-05
  • 1970-01-01
  • 1970-01-01
  • 2022-10-22
  • 2020-01-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多