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

179
Vistas
How to compile Typescript to JS that uses ES6 modules?

My tsconfig.json file contains

{
    "compilerOptions": {
        "module": "esnext",
        "target": "esnext",
    }
}

But the compiled JS files still use exports/require syntax.

How do I fix this?

EDIT:

My directory structure is as follows

- APIs/
  - emails/
    - sendEmail.ts
  - oldFiles/
    - file1.js
    - file2.js
- index.js
- tsconfig.json
- package.json

I am running tsc using the command tsc APIs/emails/sendEmail.ts from the root directory.

about 4 years ago · Santiago Gelvez
2 Respuestas
Responde la pregunta

0

Those settings are correct, so most likely you're not actually using that tsconfig.json file. For instance, if you do tsc someFile.ts, tsc doesn't use the tsconfig.json (surprisingly). Your best bet is probably to add an includes to your configuration (so tsc knows what it's compiling) and then compile simply by invoking tsc, which will look for a local tsconfig.json.

{
    "compilerOptions": {
        "module": "esnext",
        "target": "esnext"
    },
    "include": ["**/*.ts"]
}

Then in package.json (for instance):

// ...
"scripts": {
    "build": "tsc"
}
// ...
about 4 years ago · Santiago Gelvez Denunciar

0

This config should work. But it's tsconfig.json not tsconfig.js.

about 4 years ago · Santiago Gelvez 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