@adonisjs-community/modules

中文文档
2.0.0发布于 2026/05/22MITES Module零依赖近 30 天下载 2410

An easy and ergonomic way to scaffold your AdonisJS projects !

原始使用文档
文档目录7 节
  1. Introduction
  2. Installation
  3. Getting Started
  4. That's it !
  5. Particularities ( @adonisjs/lucid )
  6. License
  7. Contributing

Modules

An easy and ergonomic way to scaffold your AdonisJS projects !

Introduction

@adonisjs-community/modules provides a set of commands based on adonisjs/core commands to help you quickly scaffold your AdonisJS projects into modules (more accurately into feature-based subdirectories). This allows you to organize your code in a modular way, making it easier to maintain and scale your application.

├── app
│  ├── auth
│  │  ├── controllers
│  │  ├── services
│  │  └── models
│  └── users
│     ├── exceptions
│     ├── factories
│     └── validators

Installation

You can install Modules in your AdonisJS project using the following command:

node ace add @adonisjs-community/modules

Getting Started

After installation, you can create a new module using the make:module command:

node ace make:module auth

This will create a new module named auth in the /app directory, as well as registering a new alias for the path resolution in your package.json file:

{
  "imports": {
    "...",
    "#auth/*": "./app/auth/*.js"
  }
}

That's it !

You can now reuse the @adonisjs/core and @adonisjs/lucid make commands with flag -m (--module) to create controllers, models, views, etc., within your module. For example:

node ace make:controller sign_in -m=auth
node ace make:controller sign_in --module auth

This command will create a new controller file named sign_in_controller.ts in the auth module.

At this point, you can refer to the AdonisJS commands documentation to learn more about the available commands and how to use them.

Particularities (@adonisjs/lucid)

When using the @adonisjs/lucid commands, you can also specify the module where you want to create your models, migrations, and factories.

That said, when generating a model, the -m alias will not work, as this alias is already used to specify if the codemods should generate a migration for the model.

Last thing to note, the generated migrations will be placed in the database/migrations directory and not inside the module directory. This is because migrations are global to the application and not specific to a module. Thus, order of execution is important, and having them in a single directory allows you to manage them more easily.

License

Modules is open-sourced software licensed under the MIT license.

Contributing

We welcome contributions to the Modules package! If you have ideas, suggestions, or improvements, please feel free to open an issue or submit a pull request.

版本与发布记录

@adonisjs-community/modules 共发布 3 个版本,首次发布于 2025/06/08;过去 12 个月发布了 1 个版本。

版本发布日期距今
2.0.0latest2026/05/225 个月前
1.1.02025/06/291.4 年前
1.0.02025/06/081.4 年前

关于 @adonisjs-community/modules 的常见问题

@adonisjs-community/modules 是什么?

An easy and ergonomic way to scaffold your AdonisJS projects !

如何安装 @adonisjs-community/modules?

在项目目录运行 npm install @adonisjs-community/modules,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@adonisjs/core(^7.0.0-next.23)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@adonisjs-community/modules 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/adonisjs-community__modules 是否存在。

@adonisjs-community/modules 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@adonisjs-community/modules 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@adonisjs-community/modules 可以商用吗?

@adonisjs-community/modules 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@adonisjs-community/modules 的下载量有多少?

根据 npm 官方下载统计,@adonisjs-community/modules 在 2026/10/05 – 2026/11/03 这 30 天内被下载 2,410 次,日均约 80 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@adonisjs-community/modules 还在维护吗?

最新版本 2.0.0 发布于 2026/05/22(5 个月前);至今共发布 3 个版本,其中过去 12 个月发布了 1 个;首次发布于 2025/06/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。