Folder structure is a very controversial topic. Though there are many clean ways to structure your project, we will use the following code for the remainder of our chapters:
chapter2 ├── app.js ├── package.json ├── node_modules │└── npm package folders ├── src │├── lib │├── models │├── routes └── test
Let's take a look this at in detail:
app.js
: It is conventional to have the mainapp.js
file in the root directory. Theapp.js
is the entry point of our application and will be used to launch the server.package.json:
As with any Node.js app, we havepackage.json
in the root folder specifying our application name and version as well as all of our npm dependencies.node_modules:
Thenode_modules
folder and its content are generated via npm installation and should usually be ignored in your version control of choice because it depends on the platform the app runs on. Having said that, according to the npm FAQ, it is probably better to commit thenode_modules
folder...