EventEmitter failing when uploading website

Hello. I don’t know if this is ok for this forum. But I have recently published my Three.js website, where I use EventEmitter.
I have implemented this with node.js (npm), and this works great. But now that I have launched the website, it does now work.

I get this error: “SyntaxError: Importing binding name ‘EventEmitter’ is not found.”

This is how I import EventEmitter:

import { EventEmitter } from "/node_modules/events/events.js"

I don’t know why this does not work, and I would really appreciate if someone could help. It is perhaps just something really obvious that I have missed.

This is how my folders are listed up. I am importing EventEmitter from resources.js.

You shouldn’t import directly from node_modules - just import EventEmitter from 'events'; should be enough (according to this package at least.)

Consider using a bundler like vite to make all this module-importing-stuff less troublesome.

Unfortunately not, that is how I wrote it in the beginning.
But then I get the following error:
“TypeError: Module specifier, ‘events’ does not start with “/”, “./”, or “…/”. Referenced from https://alexanderrubino.com/Experience/Utils/resources.js

Therefore I changed it to the new code, since I had read some other forums. However, those questions where about importing THREE. Where I changed:

import * as THREE from 'three;


import * as THREE from '/node_modules/three/build/three.module.js';

So I figured I had to do the same with EventEmitter.

Can’t imagine circumstances under which this would be a good idea.

Quite literally just do npm create vite - then copy your stuff from experience and css to the src folder vite will create for you (and change imports back to normal - not the node_modules/... stuff.) You done in like 4-5 minutes - and you’ll save yourself quite a bit of headache in the future.

I am not quite sure what file you mean.

I did this back when I first created the project.

What folder do you mean? Is it inside of the folder “node_modules”?
Perhaps one of these?

As earlier - there’s already a getting-started for vite, ain’t a super long read :sweat_smile:

(Keep in mind - it’s npm create, in a new directory, not npm install.)

I believe I might have done something wrong at the very start.
After searching around, I found this link: Deploying a Static Site | Vite
Which states that you can launch website with help of command npm run build.

Currently I have set up my website using FileZilla, and treating it like a normal HTML, CSS and JavaScript website. Was I wrong for doing this?

And if I was, how do I deploy my site website onto the web? Since a lot of the tutorials are using Github Pages, which is not ideal since I have my own domain.

Note: I’m new to web development

  1. No tutorials, no gh-pages, just cd / && mkdir my-new-project && cd my-new-project
  2. npm create vite
  3. Click-through-questions-vite-asks.
  4. Copy files from your old project to src folder of the project that vite creates for you.
  5. npm run build
  6. Project is built and bundled into build/ directory - it’s a static site there, you can just copy contents of build/ to your hosting and it’s ready.

I’m sorry, but I don’t understand which src folder you mean.

This is my new project that I have set up using your guide:
Screenshot 2023-06-12 at 23.03.34