简体   繁体   中英

Angular 2 and Node.js project structure

I am struggling with the project structure for a Node.js and Angular 2 website. I use: Nodejs + Express for the server side. Angular 2 for the client side.

In most guides I found, people put both technologies in the same project. They have a client and server folder but the package.json is in the root. This seems strange to me because your package.json will get confusing because it's mixed with server and client side dependencies.

I was thinking of creating 2 Projects: One for Node.js server-side and one for Angular 2 client-side. But I am not sure if this will work and if this is the correct structure.

Is there a reason that people put everything in one project? Or is it better to create 2 projects?

I always try to separate as possible. So in my projects i have 2 folders backend and client (But i keep them in same repository).

Using angular cli will help you to build structure of angular project

Proxy will help you to prevent CORS.

But again it depends, because in some cases when you need server side rendering then maybe it would be better to have all together.

PS But this is my personal thoughts and this works for me pretty well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM