简体   繁体   中英

Deploy NodeJS Express on amplify

I am trying to deploy an app on AWS Amplify. The app is React front and and NodeJS Express backend. The frontend works fine, but the backend is just stuck without any reasonable explanation

My YML file is

version: 1
backend:
  phases:
    build:
      commands:
        - npm run build-backend
    postBuild:
        commands:
        - cd ..
frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    build:
      commands:
        - npm run build-frontend
  artifacts:
    baseDirectory: ./client/build
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

build backend-script:

"build-backend": "cd server && npm run start",

npm run start script:

"start": "npm install && node index.js"

The build is getting stuck on the npm install and after 10-20 minutes just "gives up" without the following log

2021-04-22T11:49:20.693Z [INFO]: > server@1.0.0 start /codebuild/output/src650104622/src/myBlog/server
                                 > npm install && node index.js
2021-04-22T11:49:26.976Z [INFO]: > bcrypt@5.0.0 install /codebuild/output/src650104622/src/myBlog/server/node_modules/bcrypt
                                 > node-pre-gyp install --fallback-to-build

Thanks

I came across this thread while looking for a solution for my project. And because there are no more answers here, I'll tell you what I could find myself.

Amplify works fine with SSG web applications (Gatsby, etc.), with SSR (React, NextJS, NuxtJS, etc.) and with simple NodeJS and ExpressJS applications (which only run on requests because Amplify uses Lambda-functions to handle it). So:

PS If you have any other information on this subject, please post it here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM