Estoy haciendo un proyecto en el que estoy usando typescript, pero tengo un problema al transformar esto al javascript y querer correrlo. al querer correr el arhivo .js tengo este problema
Error SyntaxError: Cannot use import statement outside a module
{
"compilerOptions": {
"lib": [
"es5",
"es6"
],
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"outDir": "./build",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true
},
"exclude": ["node_modules"],
"include": ["src"]
}
intente soluciones que me decian que cambiara el target o el lib pero esto hace que deje de funcionar mi proyecto arrancando desde typescript. para transpilar uso
tsc
mi code en server.ts es
import {App} from './app';
import { createConnection,Connection,getConnectionOptions } from "typeorm";
import 'reflect-metadata';
import 'dotenv/config';
import { GrandTotalController } from './apiServices/accounting/grandtotal/grandtotal.controller';
import { AuthController } from './apiServices/auth/auth.controller';
import {validateEnv} from './utils/validateEnv';
import { OrganizationController } from './apiServices/organization/organization.controller';
validateEnv();
createConnection()
.then(async connection=>{
const app = new App([
new GrandTotalController(),
new AuthController(),
new OrganizationController(),
// new AuthenticationController,
// new AccountMonthController
],
5000);
await app.listen();
}).catch(error=>{
console.log(`Error ${error}`.red);
});
cualquier consejo se les agradece