I am trying to package up some modules that I have been working on. I have five modules, split in to five files. Four of them are the actual outward-facing modules that I want the user to be able to install. The other one is a support module that they all need to function correctly. They are all stored in the same directory. I want to be able to specify each as a separate module in the same directory. But as far as I can tell, one can only define a single module in package.json
.
Is there a way to specify multiple modules? If not, that means this must be a bad practice. How should I structure my module's exports to move it in to one main module?
If you use the two-package. json project structure, you'll only have your devDependencies in your development package. json and your dependencies in your app package.
In terms of keeping things simple, it is easier to only have to maintain a single package. json file, but there is nothing inherently wrong with multiple package. json files within a repo.
you can just open it with nano and edit it manually...
Currently there's not a supported way of having a separate package.json
file for each module you'll be publishing within the same directory. And really, this makes sense, as each package you deploy may have issues, feature requests, bugs, etc that need to be handled separately and don't force updates of the others. Separating these out will allow you to focus on the maintenance of each independently, and also allow the consumers of these modules to include them separately. A lot of larger scale projects who have started by creating something they think people will like, end up having the thing that everyone actually use be the random sub-project that was created separately.
So separate directories, and separate package.json
files, then include dependencies within the package.json
for each. If you haven't already seen there's a couple good writeups to help development of node packages here:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With