[英]Angular Project Structure with separate package.json files
I saw this Project Structure in Angular with Node.js as backend, where the Angular node modules and package.json were in the "app" folder, while the node.js' node modules and package.json were in the root of the project. I saw this Project Structure in Angular with Node.js as backend, where the Angular node modules and package.json were in the "app" folder, while the node.js' node modules and package.json were in the root of the project. (watch picture)
(看图片)
How do i get the requested outcome?我如何获得要求的结果?
Step 1:- Run npm i @angular/cli@latest in command prompt第 1 步:- 在命令提示符下运行npm i @angular/cli@latest
Step 2:- create a empty folder.第 2 步:- 创建一个空文件夹。
Step 3:- go to your newly created folder inside command prompt.第 3 步:- go 到命令提示符内新创建的文件夹。
Step 4:- run npm init第 4 步:- 运行npm 初始化
Step 5:- then run ng new my-app第 5 步:- 然后运行ng new my-app
Step 6:- then run touch server.js第 6 步:- 然后运行touch server.js
I recommand that you use NX https://nx.dev/ , it will give you a perfect structure and many benefits of monorepos, you can have multiple angular apps and a node backend taht you can it as an app like this我建议您使用 NX https://nx.dev/ ,它将为您提供完美的结构和 monorepos 的许多好处,您可以拥有多个 angular 应用程序和一个节点后端,您可以将其作为这样的应用程序
ng g node-app backend-api
You will have a structure like this:您将拥有这样的结构:
apps/
angularApp-1/
angularApp-1-e2e/
angularApp-2/
angularApp-2-e2e/
api/ //your node app
src/
app/
assets/
environemnts/
main.ts
jest.config.js
tsconfig.app.json
tsconfig.spec.json
tslint.json
libs/
tools/
angular.json
nx.json
package.json
tsconfig.json
tslint.json
The node_modules folders should be seperated between the Angular front end and the Node backend. node_modules 文件夹应该在 Angular 前端和 Node 后端之间分开。 Eg A standard project structure for a full stack angaulr/node app should be something like.
例如,全栈angaulr/node 应用程序的标准项目结构应该类似于。
.
├── ProjectName
| ├── angular-app-name
| └── server
For a Project structure like this run对于像这样运行的项目结构
From what I can tell you want something like this, with your angular app sitting within the node backend.据我所知,你想要这样的东西,你的 angular 应用程序位于节点后端。
.
├── ProjectName
| ├── angular-app-name
| └── server.js
| └── node_modules
I personally think the more standard project-> backend/frontend structure makes more sense, but both will work fine.我个人认为更标准的项目-> 后端/前端结构更有意义,但两者都可以正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.