Unable to find the imported file or module 'events'
IOIIOOIO opened this issue · 2 comments
On compilation I receive the following error:
Unable to find the imported file or module 'events'.
the source of the error is on line 2
of index.js
:
const EventEmitter = require('events').EventEmitter
.
This is an old project that was previously working. I have tried deleting my node_modules
directory and reinstalled packages - but still the same error.
I solved this by adding the events module to my package.json:
npm i events
I assume yt-player doesn't pull this in automatically because it may or may not be needed depending on your target.
The above does not solve the problem, at least in Node 16.13.0. It gets rid of the runtime error but then the players don't load. To use the events
npm package, which matches the Node.js 11.13.0 API, the import should be:
const EventEmitter = require('events')
instead of
const EventEmitter = require('events').EventEmitter