How to use the ‘main’ parameter in package.json?

I have done quite some search already. However, still having doubts about the ‘main’ parameter in the package.json of a Node project.

  1. How would filling in this field help? Asking in another way, can I start the module in a different style if this field presents?
  2. Can I have more than one script filled into the main parameter? If yes, would they be started as two threads? If no, how can I start two scripts in a module and having them run in parallel?

I know that the second question is quite weird. It is because I have hosted a Node.js application on OpenShift but the application consists of two main components. One being a REST API and one being a notification delivering service.

I am afraid that the notification delivering process would block the REST API if they were implemented as a single thread. However, they have to connect to the same MongoDB cartridge. Moreover, I would like to save one gear if both the components could be serving in the same gear if possible.

Any suggestions are welcome.

7 Answers
7

Leave a Comment