Is there a way to compile Node.js code to regular JavaScript? I've wanted to use Node.js code for my web application for a while. I've tried to use Express, but there was no way I could make it work without converting the HTML file to EJS. I know it is possible because of the way Create React App builds, but I don't know how to achieve that.
Any solution would help, and it would also help me if you could answer some of these questions (these are some that I tried and gave up on):
You are mixing up a lot of concepts and I would strongly suggest reading more about JavaScript and the difference between executing it on the frontend (web browsers) and the backend (NodeJS)...
Here are a few (quick) answers to some of your questions:
document object only exists in a web browser environment, it has no meaning in a NodeJS environment which is a backend.require is a NodeJS API to load CommonJS packages, it does not exist in a web browser environment. There are alternatives like RequireJS or Browserify, or you can use import for ES modules (with proper CORS details set up).If you are trying to build a web application, you could start by looking into JS frameworks that do the heavy lifting for you like Svelte, Angular, React, Vue (to name only the most popular ones).