0
respostas

[Bug] Não starta o servidor.

PS D:\Study\Web - FrontEnd\TypeScript\TypeScript - construção de uma API com tipagem segura\typescript-para-backend-configuracao-inicial> node .\server.js
file:///D:/Study/Web%20-%20FrontEnd/TypeScript/TypeScript%20-%20constru%C3%A7%C3%A3o%20de%20uma%20API%20com%20tipagem%20segura/typescript-para-backend-configuracao-inicial/server.js:2
Object.defineProperty(exports, "__esModule", { value: true });
                      ^

ReferenceError: exports is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and 'D:\Study\Web - FrontEnd\TypeScript\TypeScript - construção de uma 
API com tipagem segura\typescript-para-backend-configuracao-inicial\package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///D:/Study/Web%20-%20FrontEnd/TypeScript/TypeScript%20-%20constru%C3%A7%C3%A3o%20de%20uma%20API%20com%20tipagem%20segura/typescript-para-backend-configuracao-inicial/server.js:2:23
    at ModuleJob.run (node:internal/modules/esm/module_job:217:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async loadESM (node:internal/process/esm_loader:34:7)
    at async handleMainPromise (node:internal/modules/run_main:66:12)

Node.js v20.8.1
PS D:\Study\Web - FrontEnd\TypeScript\TypeScript - construção de uma API com tipagem segura\typescript-para-backend-configuracao-inicial>
{
  "compilerOptions": {
    "module": "ES6",
    "esModuleInterop": true,
    "noImplicitAny": true,
    "noEmitOnError": true,
  },
  "include": ["./src/**/*", "./server.ts"]
}
{
  "name": "typescript",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "tsc-watch --onSuccess \"node build/server.js\""
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^5.62.0",
    "eslint": "^8.47.0",
    "eslint-config-standard-with-typescript": "^37.0.0",
    "eslint-plugin-import": "^2.28.0",
    "eslint-plugin-n": "^16.0.1",
    "eslint-plugin-promise": "^6.1.1",
    "typescript": "^5.2.2"
  },
  "dependencies": {
    "express": "^4.21.1",
    "tsc-watch": "^6.0.4"
  }
}