primus / eventemitter3

EventEmitter3 - Because there's also a number 2. And we're faster.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

require is not defined, in Vite

Nefcanto opened this issue · comments

Hi

I want to migrate from CRA to Vite.

  1. Create a simple Vite app using its react template.

  2. Install eventemitter3

  3. Inside App.jsx add this line to the top:

    var EventEmitter = require('eventemitter3');
    

You get this error inside the browser's console:

Uncaught ReferenceError: require is not defined

Since eventemitter3 is the only dependency that we use that is used this way and other libraries are imported, can we use imports to use event emitter too?

Fixed by #252.