This question has been completely edited in hopes that it will be reopened.
The naming of the main Node.js file is something left to the user and and does not seem to be defined by any well established convention. In hopes of finding a good name, I am curious if there are naming conventions in other parts of the Node.js ecosystem that might suggest a name to use.
Some names I have seen are: app.js
, index.js
, main.js
, server.js
, etc.
Please provide only well documented standards in answers.
index.js
has a special usage in Node.js. From the Module docs.I prefer to use
app.js
or evenmain.js
NPM seems to suggest a standard whereby one can define the primary file in the
package.json
file like so:If no such property is set, NPM looks for a
server.js
file in the root of the package. Ifserver.js
exists, it will be run with Node.This default seems to be a strong suggestion that the name
server.js
should be the standard.The two predominant filenames are 'app.js' & 'server.js'. Its better to go with 'server.js'. This is for nodejs applications. In the case of libraries, most libraries use 'index.js' and specify it in their 'main' param in the package.json file.
From what I have seen, app.js is the most universally accepted.
I personally prefer server.js, but this is probably biased in that I run a massive Single Page Application so all my files are .... javascript ..... and I have an app.js controller for my front-end. So it helps me distinguish the two.
do you know how well-established conventions start? you make a decision that is logical, and forthrightly forward it with resolute certainty - then others will follow. there clearly is no well established convention, so pick one and tell it to others.