Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

177
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda