将角度应用程序部署到AWS Elastic Beanstalk [英] Deploying angular app to AWS Elastic beanstalk
问题描述
我正在尝试将一个非常基本的角度应用程序部署到弹性beantalk中.该项目是使用angular cli创建的.我尚未对该项目中的文件进行任何更改.
I’m trying to deploy a very basic angular app to elastic beanstalk. The project was created using the angular cli. I have not made any changes to the files in this project.
这是我部署应用程序所采取的步骤
Here are the steps I took to deploy the app
- 在项目的根文件夹中执行了"ng build"
- 将@ angular/cli依赖项从devDependencies移至package.json中的依赖项
- 压缩dist文件夹的内容以及package.json
- 将zip文件夹部署到配置了node.js平台,节点版本8.11.3的AWS EB,与我的本地环境相同.
当我检查eb-activity.log时,总是出现"npm安装失败"错误.
I always end up with a ‘npm install failed’ error when I check eb-activity.log.
我在这里错过了一些琐碎的事情吗?非常感谢将角度应用程序部署到EB的任何帮助.
Am I missing something trivial here? Would really appreciate any help with deploying angular apps to EB.
推荐答案
解决了部署问题!我使用express创建服务器并提供我的角度应用程序.我需要将server.js添加到我的dist/文件夹中.我的server.js文件看起来像这样
Got the deployment issue resolved! I used express to create a server and serve my angular app. I needed to add server.js to my dist/ folder. My server.js file looked like so
const express = require('express');
const http = require('http');
const app = express();
const port = process.env.PORT || 3001;
app.use(express.static(__dirname));
const server = http.createServer(app);
server.listen(port, ()=> console.log("Running..."));
这篇关于将角度应用程序部署到AWS Elastic Beanstalk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!