Heroku无法启动应用程序-收到语法错误

时间:2019-06-24 11:13:13

标签: heroku nodemon heroku-ci

我有一个Nodejs应用程序,该应用程序在本地计算机上运行良好。我正在尝试部署到Heroku。部署工作正常,但是应用程序无法启动。我正在使用Koa和Typescript。我首先收到一个“找不到Nodemon的错误”,并添加了似乎可以解决该问题的Procfile。但是,我不知道如何解决这个新错误。

我正在直接从Github部署它(例如,我推送到Git并从那里部署到Heroku)。

感谢您的光临

Heroku日志错误

019-06-24T10:55:35.628075+00:00 heroku[web.1]: State changed from crashed to starting
2019-06-24T10:55:40.080980+00:00 heroku[web.1]: Starting process with command `node src/server.ts`                  )
2019-06-24T10:55:42.382747+00:00 heroku[web.1]: State changed from starting to crashed
2019-06-24T10:55:42.361956+00:00 heroku[web.1]: Process exited with status 1
2019-06-24T10:55:42.287058+00:00 app[web.1]: /app/src/server.ts:1
2019-06-24T10:55:42.287088+00:00 app[web.1]: import { config } from './config/config';
2019-06-24T10:55:42.287091+00:00 app[web.1]: ^
2019-06-24T10:55:42.287093+00:00 app[web.1]:
2019-06-24T10:55:42.287094+00:00 app[web.1]: SyntaxError: Unexpected token {
2019-06-24T10:55:42.287097+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:721:23)
2019-06-24T10:55:42.287099+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
2019-06-24T10:55:42.287101+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:653:32)
2019-06-24T10:55:42.287103+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
2019-06-24T10:55:42.287105+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:585:3)
2019-06-24T10:55:42.287106+00:00 app[web.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
2019-06-24T10:55:42.287108+00:00 app[web.1]: at startup (internal/bootstrap/node.js:283:19)
2019-06-24T10:55:42.287111+00:00 app[web.1]: at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

Procfile

web: node src/server.ts

tsconfig.json

{
    "compileOnSave": false,
    "compilerOptions": {
      "paths": { "*": ["types/*"] },
      "noImplicitAny": false,
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "moduleResolution" : "node",
      "lib": [
        "es2018"
      ],
      "types": [
        "node"
      ],
      "sourceMap": true,
      "baseUrl": "./src"
    },
    "exclude": [
      "node_modules",
      "**/*.spec.ts"
    ]
  }

package.json

{
  "name": "graphql-api",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "test": "cross-env NODE_PATH=./src mocha --timeout 25000 --exit -r ts-node/register ./test/**/*.test.ts",
    "start": "nodemon"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "nodemon": "^1.19.1",
    "typescript": "^3.5.1",
    "chai": "^4.2.0",
    "chai-http": "^4.3.0",
    "mocha": "^6.1.4"
  },
  "dependencies": {
    "@babel/runtime": "^7.4.5",
    "@types/mocha": "^5.2.7",
    "@types/neo4j": "^2.0.2",
    "apollo-server": "^2.6.2",
    "apollo-server-koa": "^2.6.3",
    "babel-plugin-transform-runtime": "^6.23.0",
    "bcryptjs": "^2.4.3",
    "dotenv": "^8.0.0",
    "fs": "0.0.1-security",
    "graphql": "^14.3.1",
    "graphql-voyager": "^1.0.0-rc.27",
    "knex": "^0.17.6",
    "koa": "^2.7.0",
    "koa-bodyparser": "^4.2.1",
    "koa-passport": "^4.1.3",
    "koa-router": "^7.4.0",
    "koa-session": "^5.12.0",
    "moment": "^2.24.0",
    "neo4j-driver": "^1.7.5",
    "neo4j-graphql-js": "^2.5.0",
    "parse-neo4j": "^0.6.11",
    "passport": "^0.4.0",
    "passport-local": "^1.0.0",
    "path": "^0.12.7",
    "pg": "^7.11.0",
    "ts-node": "^8.2.0",
    "tsconfig-paths": "^3.8.0",
    "winston": "^3.2.1"
  }
}

nodemon.json

{
    "watch": ["./src"],
    "ext": "ts",
    "exec": "ts-node -r tsconfig-paths/register ./src/server.ts",
    "ignore": ["database/migrations/*"] 
   }

0 个答案:

没有答案