Heroku deployment fails with missing script: start

微笑、不失礼 提交于 2021-02-11 13:54:19

问题


2020-01-25T14:33:23.080927+00:00 heroku[web.1]: Starting process with command `npm start`

2020-01-25T14:33:24.893568+00:00 heroku[web.1]: State changed from starting to crashed

2020-01-25T14:33:24.822413+00:00 app[web.1]: npm ERR! missing script: start

2020-01-25T14:33:24.829039+00:00 app[web.1]: 

2020-01-25T14:33:24.829298+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:

2020-01-25T14:33:24.829400+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2020-01-
25T14_33_24_823Z-debug.log

2020-01-25T14:33:24.875898+00:00 heroku[web.1]: Process exited with status 1

2020-01-25T14:33:27.000000+00:00 app[api]: Build succeeded

2020-01-25T14:34:56.808298+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=hyperrestaurant.herokuapp.com request_id=3dc7142e-f261-4fc4-a9fd-c04b20a837f1 fwd="204.9.220.50" dyno= connect= service= status=503 bytes= protocol=https

2020-01-25T14:34:57.059549+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=hyperrestaurant.herokuapp.com request_id=9f22f080-cb8d-4ffc-a62a-216397f4fa40 fwd="204.9.220.50" dyno= connect= service= status=503 bytes= protocol=https

this is my pakage.json

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

  "version": "4.0.1",

  "description": "",

  "main": "index.js",

  "scripts": {

    "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"
  },
  "author": "",

  "license": "ISC",

  "devDependencies": {

    "@babel/core": "^7.1.5",

    "@babel/plugin-proposal-class-properties": "^7.1.0",

    "@babel/preset-env": "^7.1.5",

    "@babel/preset-es2016": "^7.0.0-beta.53",

    "@babel/preset-react": "^7.0.0",

    "@babel/preset-stage-0": "^7.0.0",

    "@babel/register": "^7.0.0",

    "autoprefixer": "^9.3.1",

    "axios": "^0.18.0",

    "babel-core": "^6.26.3",

    "babel-loader": "^8.0.4",

    "babel-preset-env": "^1.7.0",

    "browser-sync": "^2.26.3",

    "clean-webpack-plugin": "^0.1.19",

    "css-loader": "^1.0.1",

    "extract-text-webpack-plugin": "^4.0.0-beta.0",

    "gulp": "^4.0.0",

    "gulp-autoprefixer": "^3.1.1",

    "gulp-edgejs": "^0.2.4",

    "gulp-imagemin": "^5.0.3",

    "gulp-pretty-url": "^0.1.1",

    "gulp-sass": "^3.0.0",

    "har-validator": "^5.1.3",

    "html-webpack-plugin": "^3.2.0",

    "jest": "^24.8.0",

    "mini-css-extract-plugin": "^0.4.4",

    "node-sass": "^4.10.0",

    "postcss-loader": "^3.0.0",

    "prettier": "^1.15.1",

    "prettier-loader": "^2.1.1",

    "react": "^16.8.6",

    "react-dom": "^16.8.6",

    "react-redux": "^5.1.0",

    "sass-loader": "^7.1.0",

    "style-loader": "^0.23.1",

    "uglify-es": "^3.3.9",

    "uglifyjs-webpack-plugin": "^1.3.0",

    "webpack": "^4.25.1",

    "webpack-cli": "^3.1.2",

    "webpack-md5-hash": "0.0.6"

  },
  "dependencies": {
    "@babel/plugin-proposal-decorators": "^7.1.6",

    "@babel/plugin-syntax-dynamic-import": "^7.0.0",

    "@babel/plugin-transform-async-to-generator": "^7.1.0",

    "babel-plugin-transform-react-jsx": "^6.24.1",

    "express": "^4.17.1",

    "gulp-pug": "^4.0.1",

    "hyperapp": "^0.12.0",

    "serve-static": "^1.14.1",

    "svelte": "^3.4.3",

    "svelte-loader": "^2.13.4",

    "webpack-dev-server": "^3.1.14"

  }
}

and my server.js

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:


You are missing the command in your package.json in the scripts part.

Add this start line to that:

...
  "scripts": {
    "start": "node server.js",
    "test": "jest",
...

Or anything else you use to start your application.

NOTE: in your package.json you have a main script defined as index.js and you posted a file server.js that looks like the main entry point. Maybe its intentional, but I use to have them the same.



来源:https://stackoverflow.com/questions/59910439/heroku-deployment-fails-with-missing-script-start

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!