1
resposta

Error no npm start.

Estou com o seguinte erro ao tentar rodar o servidor.

> API-Voll_Med@1.0.0 start
> node -r ts-node/register ./src/server.ts

/Users/andersonsilva/Documents/Developer/allura/backend/vollmed-api-swiftui/node_modules/ts-node/src/index.ts:859
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^
TSError: ⨯ Unable to compile TypeScript:
src/consultas/consultaRoutes.ts:14:26 - error TS2769: No overload matches this call.
  The last overload gave the following error.
    Argument of type '(req: Request, res: Response) => Promise<Response>' is not assignable to parameter of type 'Application<Record<string, any>>'.
      Type '(req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>) => Promise<...>' is missing the following properties from type 'Application<Record<string, any>>': init, defaultConfiguration, engine, set, and 63 more.

14 consultaRouter.post("/", criaConsulta);
                            ~~~~~~~~~~~~

  node_modules/@types/express-serve-static-core/index.d.ts:168:5
    168     (path: PathParams, subApplication: Application): T;
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The last overload is declared here.
src/consultas/consultaRoutes.ts:15:25 - error TS2769: No overload matches this call.
  The last overload gave the following error.
    Argument of type '(req: Request, res: Response) => Promise<Response>' is not assignable to parameter of type 'Application<Record<string, any>>'.
      Type '(req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>) => Promise<...>' is missing the following properties from type 'Application<Record<string, any>>': init, defaultConfiguration, engine, set, and 63 more.

15 consultaRouter.get("/", listaConsultas);
                           ~~~~~~~~~~~~~~

  node_modules/@types/express-serve-static-core/index.d.ts:168:5
    168     (path: PathParams, subApplication: Application): T;
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The last overload is declared here.

    at createTSError (/Users/andersonsilva/Documents/Developer/allura/backend/vollmed-api-swiftui/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/Users/andersonsilva/Documents/Developer/allura/backend/vollmed-api-swiftui/node_modules/ts-node/src/index.ts:863:19)
    at getOutput (/Users/andersonsilva/Documents/Developer/allura/backend/vollmed-api-swiftui/node_modules/ts-node/src/index.ts:1077:36)
    at Object.compile (/Users/andersonsilva/Documents/Developer/allura/backend/vollmed-api-swiftui/node_modules/ts-node/src/index.ts:1433:41)
    at Module.m._compile (/Users/andersonsilva/Documents/Developer/allura/backend/vollmed-api-swiftui/node_modules/ts-node/src/index.ts:1617:30)
    at loadTS (node:internal/modules/cjs/loader:1815:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/andersonsilva/Documents/Developer/allura/backend/vollmed-api-swiftui/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1458:32)
    at Function._load (node:internal/modules/cjs/loader:1275:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14) {
  diagnosticCodes: [ 2769, 2769 ]
}
1 resposta

Olá, Anderson. Tudo bem?

Verifica, por favor, a versão do Node que está instalada, você pode fazer isso com o comando node -v. Eu fiz o teste utilizando as versões 18.16.0 (sem fazer a alteração no start sugerida na atividade) e 22.14.0 (fazendo a alteração no start) e ambas funcionaram corretamente. Tente também reinstalar as dependências para garantir que sejam instaladas corretamente, basta remover a pasta node_modules e o arquivo package-lock.json e em seguida usar o comando npm install.

Espero ter ajudado!

Siga firme nos seus estudos e conte com o fórum sempre que precisar!

Abraços :)

Caso este post tenha lhe ajudado, por favor, marcar como solucionado