简体   繁体   English

在同一个Package.json文件中记录多个模块

[英]Notating Multiple Modules in the Same Package.json File

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 . 但据我所知,只能在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? 我应该如何构建模块的导出以将其移入一个主模块?

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. 目前,没有一种支持的方法可以为您将在同一目录中发布的每个模块提供单独的package.json文件。 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. 所以单独的目录和单独的package.json文件,然后在package.json包含每个目录的依赖项。 If you haven't already seen there's a couple good writeups to help development of node packages here: 如果您还没有看到有一些好的文章来帮助开发节点包:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM