yt-player icon indicating copy to clipboard operation
yt-player copied to clipboard

Unable to find the imported file or module 'events'

Open IOIIOOIO opened this issue 2 years ago • 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.

IOIIOOIO avatar Jul 06 '21 18:07 IOIIOOIO

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.

haydentech avatar Jun 07 '22 15:06 haydentech

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

hyvyys avatar May 04 '23 10:05 hyvyys