Package javascript project using npm and dividing it up into node modules to create a dependency tree
<p>I have a javascript project which is used as a utility in another project and I want to package it using npm so that more projects can use it. The project structure I created is:</p>

<pre>
Project/
|-- src/
|   |-- main.js
|   |-- index.js
|
|   |-- extensions/
|   |   |-- core-1.js
|   |   |-- ...
|   |   |-- core-n.js
|   |   |-- other-1.js
|   |   |-- ...
|   |   |-- other-n.js
|   |
</pre>

<p>The main file creates an object with some utility functions in it which is used by the extensions. The index.js file takes all the objects and functions from extensions and main and put it into a single namespace to export it. What I want is when anyone install this node module they should be able to use the utilities in the main file and core extensions. If they want to use other extensions they should have the ability to explicitly require the other extensions. Is it good idea to create separate node projects for other extensions which has dependency one the main project? or is there any other way provided by npm or node to achieve this?</p>