Angular 2 and Node.js project structure

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

In most of the manuals I found, people used both technologies in one project. They have a client and server folder, but package.json is in the root. This seems strange to me because your .json package will get confused because it mixes up with server and client side dependencies.

I was thinking of creating 2 projects: one for Node.js on the server side and one for Angular 2 on the client side. But I'm not sure if this will work, and if it's the right structure.

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

+4
source share
1 answer

I always try to separate as much as possible. So in my projects I have 2 backend and client (but I keep them in the same repository).

Using angular cli will help you build your angular project structure

Proxy helps you prevent CORS.

But again, it depends, because in some cases when you need server-side rendering, it might be better to have everything together.

PS But these are my personal thoughts, and it works pretty well for me.

+1
source

Source: https://habr.com/ru/post/1685652/


All Articles