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

727
Views
No puedo ejecutar mi proyecto TypeScript de Node.js TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Extensión de archivo desconocida ".ts" para /app/src/App.ts

Cuando intento iniciar mi aplicación en Heroku, obtuve el siguiente seguimiento de pila. Es solo una ts.app básica como la que ves con ts-node y nodemon. Si necesita más información, solo dígame eso porque es mi primera publicación. Estoy realmente interesado en cuál va a ser la respuesta.

 2020-05-30T00:03:12.201106+00:00 heroku[web.1]: Starting process with command `npm start` 2020-05-30T00:03:14.405285+00:00 app[web.1]: 2020-05-30T00:03:14.405303+00:00 app[web.1]: > discordtoornamentmanager@1.0.0 start /app 2020-05-30T00:03:14.405303+00:00 app[web.1]: > ts-node src/App.ts 2020-05-30T00:03:14.405304+00:00 app[web.1]: 2020-05-30T00:03:14.833655+00:00 app[web.1]: (node:23) ExperimentalWarning: The ESM module loader is experimental. 2020-05-30T00:03:14.839311+00:00 app[web.1]: TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /app/src/App.ts 2020-05-30T00:03:14.839312+00:00 app[web.1]: at Loader.defaultGetFormat [as _getFormat] (internal/modules/esm/get_format.js:65:15) 2020-05-30T00:03:14.839314+00:00 app[web.1]: at Loader.getFormat (internal/modules/esm/loader.js:113:42) 2020-05-30T00:03:14.839315+00:00 app[web.1]: at Loader.getModuleJob (internal/modules/esm/loader.js:244:31) 2020-05-30T00:03:14.839315+00:00 app[web.1]: at processTicksAndRejections (internal/process/task_queues.js:97:5) 2020-05-30T00:03:14.839316+00:00 app[web.1]: at Loader.import (internal/modules/esm/loader.js:178:17) 2020-05-30T00:03:14.847801+00:00 app[web.1]: npm ERR! code ELIFECYCLE 2020-05-30T00:03:14.847998+00:00 app[web.1]: npm ERR! errno 1 2020-05-30T00:03:14.848957+00:00 app[web.1]: npm ERR! discordtoornamentmanager@1.0.0 start: `ts-node src/App.ts` 2020-05-30T00:03:14.849050+00:00 app[web.1]: npm ERR! Exit status 1 2020-05-30T00:03:14.849172+00:00 app[web.1]: npm ERR! 2020-05-30T00:03:14.849254+00:00 app[web.1]: npm ERR! Failed at the discordtoornamentmanager@1.0.0 start script. 2020-05-30T00:03:14.849337+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 2020-05-30T00:03:14.854859+00:00 app[web.1]: 2020-05-30T00:03:14.854998+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 2020-05-30T00:03:14.855069+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-05-30T00_03_14_850Z-debug.log 2020-05-30T00:03:14.907689+00:00 heroku[web.1]: Process exited with status 1 2020-05-30T00:03:14.943718+00:00 heroku[web.1]: State changed from starting to crashed

Este es mi paquete.json

 { "name": "discordtoornamentmanager", "version": "1.0.0", "description": "", "main": "dist/app.js", "type": "module", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "dev": "nodemon -x ts-node src/App.ts", "start": "ts-node src/App.ts" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "@types/node": "^14.0.5", "axios": "^0.19.2", "discord.js": "^12.2.0", "pg": "^8.2.1", "reflect-metadata": "^0.1.10", "typeorm": "0.2.25", "typescript": "^3.9.3", "nodemon": "^2.0.4", "ts-node": "8.10.1" } }

Y este es mi tsconfig

 { "compilerOptions": { "lib": [ "es6" ], "target": "es6", "module": "commonjs", "moduleResolution": "node", "outDir": "dist", "resolveJsonModule": true, "emitDecoratorMetadata": true, "esModuleInterop": true, "experimentalDecorators": true, "sourceMap": true }, "include": ["src/**/*.ts"], "exclude": ["node_modules", "**/*.spec.ts"] }
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Eliminar "type": "module" de paquete.json


https://github.com/TypeStrong/ts-node/issues/935


Si no desea eliminar "type": "module" (por ejemplo, si está usando declaraciones de import en su .ts que permite la inferencia de tipos de módulos), puede usar la siguiente opción en tsconfig.json :

 { "compilerOptions": { "esModuleInterop": true, } }

Y luego puede iniciar el servidor con la configuración usando ts-node .

Instalar en pc:

 npm install -g ts-node

Correr:

 ts-node my_server.ts
over 4 years ago · Santiago Trujillo Report

0

utilizar

 node --loader ts-node/esm ./my-script.ts

en lugar de

 ts-node ./my-script.ts
over 4 years ago · Santiago Trujillo Report

0

Eliminando "type": "module" de package.json y agregando:

 "compilerOptions": { "module": "CommonJS" },

En tsconfig.json me arregló esto.

over 4 years ago · Santiago Trujillo 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!