代码之家  ›  专栏  ›  技术社区  ›  Evanss

将不在项目根目录中的应用程序部署到Heroku?

  •  3
  • Evanss  · 技术社区  · 8 年前

    我需要部署一个不在项目根目录中的节点应用程序。

    我的项目与此类似: https://github.com/graphql-boilerplates/react-fullstack-graphql/tree/master/advanced

    项目的根目录是一个React应用程序,但我不想部署它。在名为__server_的文件夹中有我的节点服务器,这是我需要部署到Heroku的内容。

    当我部署Heroku时 npm run start 在顶级package.json上。我怎么能让Heroku忽略这个并在 /server 文件夹?

    更新:我在我的项目根目录中创建了一个procfile,其中包含以下内容:

    web: ./server npm run start
    

    但当我部署时,会收到一个应用程序错误:

    2018-07-05T12:41:51.627168+00:00 app[api]: Release v4 created by user MYEMAIL@gmail.com
    2018-07-05T12:41:59.000000+00:00 app[api]: Build succeeded
    2018-07-05T12:42:02.176695+00:00 heroku[web.1]: Starting process with command `./server npm run start`
    2018-07-05T12:42:04.817337+00:00 heroku[web.1]: State changed from starting to crashed
    2018-07-05T12:42:04.701159+00:00 app[web.1]: bash: ./server: Is a directory
    2018-07-05T12:42:04.782252+00:00 heroku[web.1]: Process exited with status 126
    2018-07-05T12:42:11.974345+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=DEPLOY-NAME.herokuapp.com request_id=c2cba42e-80af-4b16-95sdfdfd-2918 fwd="86.343.251.15" dyno= connect= service= status=503 bytes= protocol=https
    
    3 回复  |  直到 8 年前
        2
  •  1
  •   Aaron J    8 年前

    {
      "scripts": {
        "heroku-prebuild": "cd app && npm install && npm run build && cd .. && cd api && npm install",
        "start": "cd api && npm start"
      }
    }
    
        3
  •  0
  •   Evanss    8 年前