2

我有一个在本地机器上运行良好的 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)

档案

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"
    ]
  }

包.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/*"] 
   }
4

0 回答 0