提问者:小点点

Heroku上的节点应用程序-获取“应用程序错误”


2020-01-28T01:42:46.028688+00:00 Heroku[web.1]:使用命令npm start启动进程

2020-01-28T01:42:45.000000+00:00APP[api]:生成成功

2020-01-28T01:42:48.451589+00:00Heroku[web.1]:状态从启动更改为崩溃

2020-01-28T01:42:48.433700+00:00 Heroku[Web.1]:进程已退出,状态为1

2020-01-28T01:42:48.377550+00:00APP[Web1]:npm错误!缺少脚本:开始

2020-01-28T01:42:48.385902+00:00应用程序[Web1]:

2020-01-28T01:42:48.386316+00:00APP[Web1]:npm错误!可以找到此运行的完整日志

IN:2020-01-28T01:42:48.386539+00:00app[web.1]:npm错误!
/app/.npm/_logs/2020-01-

28T01_42_48_378Z-调试日志

2020-01-28T01:42:49.724030+00:00 Heroku[路由器]:at=error code=h10 desc=“应用程序崩溃”

method=get path=“/”host=hyperrestauran.herokuapp.com request_id=df2c429e-7b27-40d5-93b4-

a63f4b15c8fe FWD=“146.115.31.86”Dyno=Connect=Service=Status=503 Bytes=Protocol=HTTPS

2020-01-28T01:42:50.003622+00:00 Heroku[路由器]:at=error code=h10 desc=“应用程序崩溃”

method=get path=“/favicon.ico”host=hyperrestauran.herokuapp.com request_id=c1f6be2c-35da-

4E86-97B1-59FA73EB91FB fwd=“146.115.31.86”Dyno=Connect=Service=Status=503字节=

协议=HTTPS

我的Package.json

{
  "name": "HyperApp-Starter-kit",

  "version": "4.0.1",

  "description": "",

  "main": "index.js",

  "scripts": {

    "node": "index.js",

    "test": "jest",

    "build": "gulp build",

    "dev:webpack": "webpack --mode development --env.NODE_ENV=dev",

    "build:webpack": "webpack --mode production --env.NODE_ENV=production",

    "watch": "gulp",

    "proxy": "gulp watch-proxy",

    "static:dev": "gulp static-dev",

    "static:build": "gulp static-dev",

    "imgs": "gulp imagemin"

  },

这是我的server.js,这可能是一个文件放置问题,html和css被放置在我的资产文件中。

const express = require('express')

const serveStatic = require('serve-static')

const path = require('path')

// create the express app

const app = express()

// create middleware to handle the serving the app

app.use("/", serveStatic ( path.join (__dirname, '/public')))

// serve index by default

app.get('/', function (req, res) {

  res.sendFile(__dirname + '/public/index.html')

})
// Create default port to serve the app on

const port = process.env.PORT || 5000

app.listen(port)

// Log to feedback that this is actually running

console.log('Server started on port ' + port)

共1个答案

匿名用户

尝试在“scripts”对象的package.json中添加一个开始脚本,如下所述。

它看起来应该是这样的:

{
  "name": "HyperApp-Starter-kit",
  "version": "4.0.1",
  "description": "",
  "main": "index.js",
  "scripts": {
      "start" : "node server.js"
      ...

...表示这只是package.json的一部分,我不是字面意思是类型...

这假设您可以使用命令节点server.js运行应用程序(因为您提到您的文件名为server.js)。