In node.js, it seems I run into the same 3 filenames to describe the main entry point to an app:
express-generator
package, an
It's pretty simple!
If your application is to be used in other applications: index.js
If your application is NOT to be used in other applications: server.js or app.js
As stated earlier the reasons being, when invoking npm start
, if not defined in package.json
, looks automatically for server.js
. And when including another module into your application, it looks for index.js
.
Extra:
I also tend to only use index.js
as a file name when this is automatically found somehow. This makes me aware if the file is invoked directly or indirectly.
When using npm init it makes the default index.js.