require is not defined, in Vite
Nefcanto opened this issue · comments
Saeed Nemati commented
Hi
I want to migrate from CRA to Vite.
-
Create a simple Vite app using its react template.
-
Install
eventemitter3
-
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?
Luigi Pinca commented
Fixed by #252.