Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

262
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda