在 Heroku 上部署 [用 Typescript 编写的 NodeJS 文件]

Deploying [NodeJS file written in Typescript] on Heroku

我的 NodeJS 应用程序是用 Typescript 编写的,我正在尝试将它部署到 Heroku 上。

我正在关注 YouTube 教程。

我的应用程序已部署,但显示错误。谁能告诉我这是什么问题?

是因为应用是用Typescript写的吗?

我创建了一个 Procfile 并在文件中添加了这个 [web: nodemon src/server.ts]。以便 heroku 知道在哪里可以找到服务器文件。

如果有与我的问题相关的类似问题或答案,请在此处分享 link。

答案是:

首先在 Heroku 的应用程序设置中添加所有配置变量。 第二个是在 package.json 文件

中添加 [start and engine] 脚本
"scripts": {
    "start": "node dist/server",
    "dev": "sucrase-node src/server.ts",
    "build": "sucrase ./src -d ./dist --transforms typescript,imports"
  },enter code here
  "engines": {
    "node": ">=10.0.0"
  },

回答

我的脚本package.json

"scripts": {
    "dev": "ts-node-dev --no-notify --respawn --transpile-only src/index.ts",
    "build": "tsc --build",
    "start": "node dist/index.js",
    "deloy": "git push heroku main",
    "log": "heroku logs --tail"
  },

我的档案 web: npm start