首页 > 解决方案 > 您好,这是我的 package.json 文件。但是 Heroku 告诉我 Application error 应用程序发生错误,无法提供您的页面

问题描述

您好,这是我的 json 文件格式,当我运行 node index.js 时,它在我的本地机器上运行良好。

{
  "name": "a-simple-nodejs-website",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "node index.js"
  },
  "author": "Theodore Kelechukwu Onyejiaku",
  "license": "ISC"
}

但是 Heroku 告诉我:应用程序错误应用程序发生错误,无法提供您的页面...

标签: herokudeployment

解决方案


json 文件中没有启动脚本,因此添加 =>“start”:“node index.js”。傻瓜代码示例如下

{
  "name": "a-simple-nodejs-website",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "node index.js",
    "start": "node index.js"
  },
  "author": "Theodore Kelechukwu Onyejiaku",
  "license": "ISC"
}

推荐阅读