node.js - How to Integrate angular cli project with nodejs/expressjs project
问题描述
I have 2 projects, as shown in the following images.
The Node, and Express project is in the root
folder, and the Angular CLI project inside of angular-src
folder.
I can run each project individually, back-end on port 3000 with node app.js
and front-end on port 4200 with ng serve
What is the best way to integrate both projects, and the easiest in deployment?
Full Project Folder Full Project Folder with angular src files shown
解决方案
大多数人将他们的前端 (fe) 和后端 (be) 保存在单独的存储库中。当你认为你可以有多个 fe 时,这是有道理的。
但是,将它们保存在同一个存储库中通常更容易。然后,当您部署时,您只需要克隆一个 repo。
另外,这取决于你走哪条路线。你会在你的服务器上安装 Node.js 等,还是沿着 docker 路线走?
人们经常喜欢使用 docker 来容器化他们的 fe 和 be。这种方法的好处是您只需要在您部署的每台服务器上安装一个依赖项,即 docker 本身。其他一切都存在于 docker 世界中。
此外,docker 可以轻松地从任何服务器进行 docker pull。如果出现问题,只需杀死您的 docker 容器并启动一个新容器(假设您的数据不会因此而丢失,这不是 fe 的担心,而是一个值得关注的问题)。
显然,有 docker 学习曲线,但并不太痛苦。
推荐阅读
- javascript - Javascript >>>" 到 PHP
- html - html 无法正确放置元素
- javascript - 使用 Malsup Ajax 表单提交后重定向到另一个操作
- angular - Angular PWA 应用程序基本问题
- sql - 按子句分组,我是否必须调用我在 Select 中使用的所有行?
- python - 有没有办法使用 python Telegram-Bot 获取个人资料图片更新?
- python - apache beam python sdk可以进行状态处理吗?
- c# - 实体框架 - 使用 Fluent API 配置获取相关项目而无需显式引用
- javascript - 我可以在 js 中使用类似 file_get_content 的东西吗?
- javascript - 注销时保留动态添加的 DOM 元素