Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

259
Views
Is there a way to compile Node.js code to regular JavaScript?

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):

  • Is there a way to access the document variable with express (keep in mind that I'm working with a framework that requires to have access to the document variable)?
  • Is there any way I could just import modules to my JavaScript file (basically using require() without node)?
  • Is there any way I could ship the part of Node.js that I actually need togeher with my application (and yes, it is in fact the require() function)?
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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:

  1. Code that runs in NodeJS is regular JavaScript. However if you use NodeJS APIs, it will not run in a web browser, which has a different execution environment runtime.
  2. The document object only exists in a web browser environment, it has no meaning in a NodeJS environment which is a backend.
  3. 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).
  4. Express is a server-side routing library, it is not meant to run in web browser environment.

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).

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!