#Extending builtin nodejs eventemitter class throws an error in nestjs

3 messages · Page 1 of 1 (latest)

wispy ether
#

I have a nestjs application andin that application I created a class called ChromiumCDP that extends from the builtin nodejs EventEmitter class. It is not a nodejs service etc. Just a plain class as follows

import EventEmitter from "node:events";

export class ChromiumCDP extends EventEmitter {

when I emport the class in nestjs service it throws the following error

TypeError: Class extends value undefined is not a constructor or null
  at Object.<anonymous> (C:\Users\User\Documents\GitHub\scrawlify\monorepo\services\browser\src\core\browsers\browser.cdp.ts:5:34)
  at Module._compile (node:internal/modules/cjs/loader:1562:14)
  at Object..js (node:internal/modules/cjs/loader:1699:10)
  at Module.load (node:internal/modules/cjs/loader:1313:32)
  at Function._load (node:internal/modules/cjs/loader:1123:12)
vernal hill
#

maybe

- import EventEmitter from "node:events";
+ import { EventEmitter } from "node:events";
wispy ether
#

Thanks that worked, however I went with the option of adding "esModuleInterop" to my tsconfig and it fixed the issue