📜  index.js 与 main.js - 任何代码示例

📅  最后修改于: 2022-03-11 14:55:07.307000             🧑  作者: Mango

代码示例1
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.