Heroku at=错误代码=H10 desc="应用程序崩溃"

时间:2021-03-24 23:47:26

标签: node.js typescript postgresql heroku typeorm

当我尝试在 heroku 上访问我的 api 时遇到此错误

我有 nodejs、typescript、typeORM 的项目,并在 Postgresql 中使用数据库。

我的项目链接:https://github.com/WesleyIsr4/tarefas_api/tree/main/tasks_api

2021-03-24T23:42:04.841420+00:00 heroku[web.1]: Starting process with command `npm start`
2021-03-24T23:42:06.805718+00:00 app[web.1]: 
2021-03-24T23:42:06.805731+00:00 app[web.1]: > tasks_api@0.0.1 start /app
2021-03-24T23:42:06.805731+00:00 app[web.1]: > node src/index.ts
2021-03-24T23:42:06.805731+00:00 app[web.1]: 
2021-03-24T23:42:06.871406+00:00 app[web.1]: (node:21) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
2021-03-24T23:42:06.871407+00:00 app[web.1]: (Use `node --trace-warnings ...` to show where the warning was created)
2021-03-24T23:42:06.874166+00:00 app[web.1]: /app/src/index.ts:1
2021-03-24T23:42:06.874166+00:00 app[web.1]: import "reflect-metadata";
2021-03-24T23:42:06.874167+00:00 app[web.1]: ^^^^^^
2021-03-24T23:42:06.874167+00:00 app[web.1]: 
2021-03-24T23:42:06.874168+00:00 app[web.1]: SyntaxError: Cannot use import statement outside a module
2021-03-24T23:42:06.874168+00:00 app[web.1]: at wrapSafe (internal/modules/cjs/loader.js:979:16)
2021-03-24T23:42:06.874169+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1027:27)
2021-03-24T23:42:06.874169+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
2021-03-24T23:42:06.874170+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:928:32)
2021-03-24T23:42:06.874170+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:769:14)
2021-03-24T23:42:06.874171+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
2021-03-24T23:42:06.874171+00:00 app[web.1]: at internal/main/run_main_module.js:17:47
2021-03-24T23:42:06.889434+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-03-24T23:42:06.889834+00:00 app[web.1]: npm ERR! errno 1
2021-03-24T23:42:06.896276+00:00 app[web.1]: npm ERR! tasks_api@0.0.1 start: `node src/index.ts`
2021-03-24T23:42:06.896419+00:00 app[web.1]: npm ERR! Exit status 1
2021-03-24T23:42:06.896567+00:00 app[web.1]: npm ERR!
2021-03-24T23:42:06.896657+00:00 app[web.1]: npm ERR! Failed at the tasks_api@0.0.1 start script.
2021-03-24T23:42:06.896771+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-03-24T23:42:06.905764+00:00 app[web.1]: 
2021-03-24T23:42:06.906023+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-03-24T23:42:06.906187+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2021-03-24T23_42_06_897Z-debug.log
2021-03-24T23:42:06.952487+00:00 heroku[web.1]: Process exited with status 1
2021-03-24T23:42:07.022497+00:00 heroku[web.1]: State changed from starting to crashed
2021-03-24T23:42:07.716132+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=taskedapi.herokuapp.com request_id=cb3a7f47-103e-408d-874b-c0e3466eead5 fwd="177.37.210.66" dyno= connect= service= status=503 bytes= protocol=https
2021-03-24T23:42:08.350324+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=taskedapi.herokuapp.com request_id=ead9cb26-9b21-4d6e-9630-70b13306d777 fwd="177.37.210.66" dyno= connect= service= status=503 bytes= protocol=https

1 个答案:

答案 0 :(得分:0)

Node 无法运行打字稿 (.ts) 文件。您将需要:

  • 使用类似 ts-node 的东西来编译文件
  • compile 将您的 .ts 文件转换为 .js 作为部署步骤的一部分