将角度应用程序部署到AWS Elastic Beanstalk [英] Deploying angular app to AWS Elastic beanstalk

查看:94
本文介绍了将角度应用程序部署到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

  1. 在项目的根文件夹中执行了"ng build"
  2. 将@ angular/cli依赖项从devDependencies移至package.json中的依赖项
  3. 压缩dist文件夹的内容以及package.json
  4. 将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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆