[英]Deploy NodeJS Express on amplify
I am trying to deploy an app on AWS Amplify.我正在尝试在 AWS Amplify 上部署应用程序。 The app is React front and and NodeJS Express backend.该应用程序是 React 前端和 NodeJS Express 后端。 The frontend works fine, but the backend is just stuck without any reasonable explanation前端工作正常,但后端卡在没有任何合理的解释
My YML file is我的 YML 文件是
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: npm 运行启动脚本:
"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构建卡在 npm 安装上,10-20 分钟后只是“放弃”而没有以下日志
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). Amplify 可与SSG web应用程序(Gatsby 等)、 SSR (React、NextJS、NuxtJS 等)以及简单的 NodeJS 和 ExpressJS应用程序(仅在请求上运行,因为 Amplify 使用 Lambda 函数来处理它)一起工作。 So:所以:
If you need a simple ExpressJS application for your API you can use the following serverless Ampl solution: https://docs.amplify.aws/guides/api-rest/express-server/q/platform/js/如果您的 API 需要一个简单的 ExpressJS 应用程序,您可以使用以下无服务器 Ampl 解决方案: https://docs.amplify.aws/guides/api-rest/express-server/q/platform/js/
If you need a socket.io application (or another constantly running application) you need to use AWS Fargate (uses docker images) or AWS EC2 (works on simple virtual machine with access by SSH) solutions.如果您需要socket.io 应用程序(或另一个持续运行的应用程序),您需要使用AWS Fargate (使用 docker 映像)或AWS EC2 (在通过 SSH 访问的简单虚拟机上工作)解决方案。
PS If you have any other information on this subject, please post it here. PS如果您有关于此主题的任何其他信息,请在此处发布。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.