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

175
Vistas
Node Application compiles when running

I have a typescript application which runs fine in dev mode when running through ts-node, But after build when I try to run it gives some unusual warnings or errors

my tsconfig.json

{
  "compilerOptions": {
    "incremental": true,  
    "module": "commonjs",
    "target": "es6",
    "noImplicitAny": false,
    "allowJs": true,       
    "outDir": "./build",
    "rootDir": "./src",
    "inlineSourceMap": true,
    "newLine": "LF",
    "declaration": true,
    "experimentalDecorators": true,
    "strictNullChecks": true,
    "noUnusedParameters": false,
    "noUnusedLocals": false,
    "noFallthroughCasesInSwitch": true,
    "forceConsistentCasingInFileNames": true,
    "allowUnreachableCode": false,
    "noEmitOnError": true,
    "esModuleInterop":true,
    "strict": true,
    "alwaysStrict": true, 
  },
  "skipLibCheck": true,
  "include": ["./src"],
  "exclude": ["./node_modules", "./docs", "cs-keycloak-theme", "./build"]
}

My application directory structure looks like enter image description here

And When I am building my application and running it, it shows like this enter image description here

The cpx I am doing is copying some JS file from src/ to build/ becasuse these are code generated by another script which can not run on every machine.

The point its running fine when i say ts-node src/server.ts

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to add the configuration in tsconfig that will allow JS files to be imported inside the project.

Allow JavaScript files to be imported inside your project, instead of just .ts and .tsx files. For example, this JS file:

// @filename: card.js
export const defaultCardDeck = "Heart";

When imported into a TypeScript file will raise an error:

// @filename: index.ts
import { defaultCardDeck } from "./card";
 
console.log(defaultCardDeck);

Imports fine with allowJs enabled:

// @filename: index.ts
import { defaultCardDeck } from "./card";
 
console.log(defaultCardDeck);

This flag can be used as a way to incrementally add TypeScript files into JS projects by allowing the .ts and .tsx files to live along-side existing JavaScript files.

For more details check this.

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