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

219
Visualizações
How to automatically fix node build imports that are without ".js" at the end?

I have a personal project using node.js, express.js and typescript.

When I run command to build project, it does all right.

But when I try to run it, it crashes, because all imports are "wrong", have a look:

The file dist/index.js has this import:

import app from './core/app';
...

BUT, if I make this change to the import, it runs ok:

import app from './core/app.js';
...

I didn't want to create a script file to do this, how can I solve it?

I'm currently using node version 16.0.

Here is my folder structure

enter image description here

Here is my index.ts

import app from 'src/core/app';

/**
 * Initializing server
 */
app.listen(app.get('port'), () => console.log('Application running -> true'));

Here is my tsconfig.json

{
    "compilerOptions": {
        "lib": ["ES2021"],
        "target": "ES2021",
        "module": "ES2020",
        "moduleResolution": "node",
        "strict": true,
        "baseUrl": ".",
        "sourceMap": true,
        "outDir": "dist",
        "rootDir": "src",
        "skipLibCheck": true,
        "noImplicitAny": true,
        "esModuleInterop": true,
        "isolatedModules": true,
        "removeComments": true,
        "resolveJsonModule": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "useUnknownInCatchVariables": true,
        "allowSyntheticDefaultImports": true,
        "strictPropertyInitialization": false,
        "forceConsistentCasingInFileNames": true,
        "typeRoots": ["node_modules/@types", "src/@types"]
    },
    "include": ["src/**/*"],
    "exclude": ["node_modules", "dist"]
}
about 4 years ago · Juan Pablo Isaza
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