Heroku 错误部署:找不到模块“/app/index.js”

时间:2021-05-29 18:10:23

标签: javascript node.js typescript heroku deployment

我正在尝试部署我的 node.js 后端,但由于出现以下错误而无法部署:

enter image description here

我发现了一些关于此的问题,但这些问题并没有解决我的错误。

我的项目如下:

enter image description here

我的 package.json 如下:

{
  "name": "server",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "nodemon src/index.js",
    "start": "node ."
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "bcryptjs": "^2.4.3",
    "cors": "^2.8.5",
    "express": "^4.17.1",
    "generate-password": "^1.6.0",
    "jsonwebtoken": "^8.5.1",
    "moment": "^2.29.1",
    "morgan": "^1.10.0",
    "mysql": "^2.18.1",
    "nodemailer": "^6.6.1",
    "winston": "^3.3.3"
  },
  "devDependencies": {
    "nodemon": "^2.0.7"
  }
}

我该如何解决这个错误?

1 个答案:

答案 0 :(得分:0)

将 package.json 文件中的启动命令改为:

...
"start":"node ./src/index.js"
...