Table of contents
- 1. Problem
- 2. Solution
EventEmitter class from Node.js might cause error TS2307. Here is how to fix it.
In Node.js you can implement an event listener system using the EventEmitter class:
When executing the code above you may encounter the following errors:
error TS2307: Cannot find module ‘events’ or its corresponding type declarations.
error TS2339: Property ‘emit’ does not exist on type …
Most of the times these errors are symptoms of missing Node.js type definitions. You can resolve these problems by installing the following typings:
Tested with TypeScript 3.9.3 and Node.js 12.18.0 LTS.