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

174
Views
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 answers
Answer question

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 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!