Skip to content

AdminJS v7 - feedback, urgent issues, questions, discussions #1473

Open

Description

@dziraf

This is a thread to aggregate all questions/feedback/urgent bugs/discussions related to the recently released version 7.

Feel free to share your ideas or let us know about any issues you're facing related to migration or usage.

What's new in version 7
describes the largest changes in version 7.

Migration Guide will help you migrate your project to version 7.

Demo Application

Demo application also includes our new Themes feature. If you would like to see themes in action, use one of these credentials to sign in:

  • dark@example.com / password - a dark theme
  • no-sidebar@example.com / password - a theme which uses custom components to remove the sidebar and instead move resources to the top bar
  • custom@example.com / password - an example of a custom theme which you can build yourself in your own project (source code)

If you notice that parts of our documentation are outdated or unclear, please share that in this thread as well.

Activity

  1. pinned this issue on Apr 18, 2023
  2. ddresch commented on Apr 18, 2023

    @ddresch
    Contributor

    https://www.npmjs.com/package/@adminjs/mongoose the docs are wrong - still showing require statements.

    import { Database as MongooseDatabase, Resource as MongooseResource } from '@adminjs/mongoose';

    Using this, like in the new example app.

  3. mszula commented on Apr 18, 2023

    @mszula

    Great work guys!

    I'm really in favor of moving to ESM-only but I feel like one thing hasn't been thought through. It's cooperation with NestJS which still uses CJS and has no plans to move to ESM.

    nestjs/nest#7021

    Do you have any solution for that?

  4. dziraf commented on Apr 19, 2023

    @dziraf
    ContributorAuthor

    @mszula until Nest.js moves to ESM or starts dual packaging, you will either have to set up AdminJS express/fastify way or use dynamic imports:

    src/app.module.ts

    import { Module } from '@nestjs/common';
    
    import { AppController } from './app.controller';
    import { AppService } from './app.service';
    
    @Module({
      imports: [
        import('@adminjs/nestjs').then(({ AdminModule }) =>
          AdminModule.createAdminAsync({
            useFactory: () => ({
              adminJsOptions: { rootPath: '/' },
            }),
          }),
        ),
      ],
      controllers: [AppController],
      providers: [AppService],
    })
    export class AppModule {}

    tsconfig.json

    {
      "compilerOptions": {
        // ...
        "moduleResolution": "nodenext"
      }
    }

    Instead of import(...).then(...) in app.module.ts you can just set it up Express way in main.ts:

    import { NestFactory, HttpAdapterHost } from '@nestjs/core';
    
    import { AppModule } from './app.module';
    
    async function bootstrap() {
      const app = await NestFactory.create(AppModule);
    
      const AdminJS = await import('adminjs');
      const AdminJSExpress = await import('@adminjs/express');
    
      const expressApp = app.get(HttpAdapterHost).httpAdapter;
      const admin = new AdminJS.default({});
    
      expressApp.use(
        admin.options.rootPath,
        AdminJSExpress.default.buildRouter(admin),
      );
    
      await app.listen(3000);
    }
    bootstrap();

    Note that these changes still rely on you not actually updating to ESM, so you will have to await import(<any adminjs package>) to have it work or just import CJS versions.

    As for whether it is possible to still set it up Nest-way - maybe, I don't know. It should be in the interest of NestJS maintainers to proceed with that migration because we cannot impede our own product's development based on their choice of not supporting ESM. Technically ESM projects should be able to import CJS packages, but it doesn't seem to be the case here.

  5. dziraf commented on Apr 19, 2023

    @dziraf
    ContributorAuthor

    @ddresch Have you managed to fix your problem? From what I can see you just need to make changes to your tsconfig.json:

    "moduleResolution": "nodenext",
    "module": "nodenext",
    "target": "esnext"
    
  6. ddresch commented on Apr 19, 2023

    @ddresch
    Contributor

    Yes – I fixed all my issues now. Thanks for your feedback!

  7. Aladinndevolpment commented on Apr 19, 2023

    @Aladinndevolpment

    TypeError: Unknown file extension ".json"

  8. dziraf commented on Apr 19, 2023

    @dziraf
    ContributorAuthor

    TypeError: Unknown file extension ".json"

    import someJson from './path/to/some.json' assert { type: 'json' }
    

    or use alternatives: https://www.stefanjudis.com/snippets/how-to-import-json-files-in-es-modules-node-js/

  9. Aladinndevolpment commented on Apr 19, 2023

    @Aladinndevolpment

    TypeError: Unknown file extension ".json"

    Getting this error in adminjs 7 package with nestjs

  10. dziraf commented on Apr 19, 2023

    @dziraf
    ContributorAuthor

    Can you show full error log? This could be Nest issue since json imports work fine with every other framework I tried.

  11. Aladinndevolpment commented on Apr 19, 2023

    @Aladinndevolpment

    TypeError: Unknown file extension ".json" for E:\application\admin-mode\node_modules\adminjs\lib\locale\de\translation.json

    Node version: v16.14.0

  12. dziraf commented on Apr 19, 2023

    @dziraf
    ContributorAuthor

    @Aladinndevolpment Looks like type assertions are supported from Node 17+

  13. mickyarun commented on Apr 20, 2023

    @mickyarun

    I am stuck with this issue after upgrading to 7 both themes and typeorm is not detecting though in node_modules it exist
    image

  14. dziraf commented on Apr 20, 2023

    @dziraf
    ContributorAuthor

    @mickyarun This is the same problem @ddresch had, I think you just have to add:

    "moduleResolution": "nodenext",
    "module": "nodenext",
    "target": "esnext"
    

    to your tsconfig.json

  15. aeroldb commented on Apr 23, 2023

    @aeroldb

    @dziraf
    is this how I will register the adapter for TypeORM on nestJS?
    image

  16. 20 remaining items

  17. radekdp commented on Jul 28, 2023

    @radekdp

    Hi,
    something is wrong with the nested translations
    i18next::translator: missingKey pl translation properties.isActive.true Yes
    I have this key in my translations:
    image
    The column header in the table translates correctly, but the translation in the records is missing:
    image

    Having either the property translation or the nested properties (like *.true/*.false) works fine. It only breaks once you have both, and always seems to pick the resource ove the nested ones.

    That's right, in an earlier version of AdminJs (6.*) this worked fine

  18. smiziara commented on Aug 2, 2023

    @smiziara

    Hi,
    something is wrong with the nested translations
    i18next::translator: missingKey pl translation properties.isActive.true Yes
    I have this key in my translations:
    image
    The column header in the table translates correctly, but the translation in the records is missing:
    image

    Having either the property translation or the nested properties (like *.true/*.false) works fine. It only breaks once you have both, and always seems to pick the resource ove the nested ones.

    That's right, in an earlier version of AdminJs (6.*) this worked fine

    Seems to be because V06 just got the admin.locales and initialized the redux but V07 does a flatten+unflatten on the locales, so this *.true, *.false etc is now broken.

  19. juanmav commented on Aug 10, 2023

    @juanmav

    Hi, I wanted to add AdminJs to my expressjs and typescript project using "adminjs": "^7.2.0" with "@adminjs/express": "^6.0.0", "@adminjs/sequelize": "^4.0.0",

    and getting the error Cannot find module '@adminjs/sequelize' or its corresponding type declarations.

    My index.ts

    import express from 'express';
    import AdminJs from 'adminjs';
    import AdminJsExpress from '@adminjs/express';
    import AdminJsSequelize from '@adminjs/sequelize';
    import * as allModels from './models';
    
    const host = process.env.HOST ?? 'localhost';
    const port = process.env.PORT ? Number(process.env.PORT) : 3000;
    const app = express();
    
    AdminJs.registerAdapter({
      Resource: AdminJsSequelize.Resource,
      Database: AdminJsSequelize.Database,
    });
    
    const localModel = Object.values(allModels);
    localModel.pop(); // Remove Sequelize instance
    localModel.pop(); // Remove Sequelize instance
    
    const adminOptions =
      {
        // We pass Category to `resources`
        resources: localModel,
      }
    
    const admin = new AdminJs(adminOptions)
    const adminRouter = AdminJsExpress.buildRouter(admin)
    
    app.use(admin.options.rootPath, adminRouter);
    
    app.get('/', (req, res) => {
      res.send({ message: 'Hello API' });
    });
    
    app.listen(port, host, () => {
      console.log(`[ ready ] http://${host}:${port}`);
    });

    My tsconfig.base.json

    {
      "compileOnSave": false,
      "compilerOptions": {
        "rootDir": ".",
        "sourceMap": true,
        "declaration": false,
        "moduleResolution": "node",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "importHelpers": true,
        "target": "es2015",
        "module": "esnext",
        "lib": ["es2020", "dom"],
        "skipLibCheck": true,
        "skipDefaultLibCheck": true,
        "baseUrl": ".",
        "paths": {}
      },
      "exclude": ["node_modules", "tmp"]
    }
    

    Besides that I tried to use AdminJs version 6 but when NPM tries to resolve the version of @adminjs/express and @admin/sequelize it can not resolve the versions of the dependencies in a straigthforward way.

    Any advice how is the best way to proceed?

    Thanks in advance
    Juan Manuel

  20. niyrme commented on Aug 22, 2023

    @niyrme

    Hi, I wanted to add AdminJs to my expressjs and typescript project using "adminjs": "^7.2.0" with "@adminjs/express": "^6.0.0", "@adminjs/sequelize": "^4.0.0",

    and getting the error Cannot find module '@adminjs/sequelize' or its corresponding type declarations.

    My index.ts

    import express from 'express';
    import AdminJs from 'adminjs';
    import AdminJsExpress from '@adminjs/express';
    import AdminJsSequelize from '@adminjs/sequelize';
    import * as allModels from './models';
    
    const host = process.env.HOST ?? 'localhost';
    const port = process.env.PORT ? Number(process.env.PORT) : 3000;
    const app = express();
    
    AdminJs.registerAdapter({
      Resource: AdminJsSequelize.Resource,
      Database: AdminJsSequelize.Database,
    });
    
    const localModel = Object.values(allModels);
    localModel.pop(); // Remove Sequelize instance
    localModel.pop(); // Remove Sequelize instance
    
    const adminOptions =
      {
        // We pass Category to `resources`
        resources: localModel,
      }
    
    const admin = new AdminJs(adminOptions)
    const adminRouter = AdminJsExpress.buildRouter(admin)
    
    app.use(admin.options.rootPath, adminRouter);
    
    app.get('/', (req, res) => {
      res.send({ message: 'Hello API' });
    });
    
    app.listen(port, host, () => {
      console.log(`[ ready ] http://${host}:${port}`);
    });

    My tsconfig.base.json

    {
      "compileOnSave": false,
      "compilerOptions": {
        "rootDir": ".",
        "sourceMap": true,
        "declaration": false,
        "moduleResolution": "node",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "importHelpers": true,
        "target": "es2015",
        "module": "esnext",
        "lib": ["es2020", "dom"],
        "skipLibCheck": true,
        "skipDefaultLibCheck": true,
        "baseUrl": ".",
        "paths": {}
      },
      "exclude": ["node_modules", "tmp"]
    }
    

    Besides that I tried to use AdminJs version 6 but when NPM tries to resolve the version of @adminjs/express and @admin/sequelize it can not resolve the versions of the dependencies in a straigthforward way.

    Any advice how is the best way to proceed?

    Thanks in advance
    Juan Manuel

    I had that issue as well first, but setting module and moduleResolution to "NodeNext" in the tsconfig.json seems to resolve that issue

  21. juanmav commented on Aug 24, 2023

    @juanmav

    I had that issue as well first, but setting module and moduleResolution to "NodeNext" in the tsconfig.json seems to resolve that issue

    That helped! However I had to modify the imports in this "hacky" way

    const AdminJs = (await import('adminjs')).default;
    const AdminJsExpress = (await import('@adminjs/express')).default;
    const AdminJsSequelize = (await import('@adminjs/sequelize')).default;
    
  22. rlamorea commented on Aug 25, 2023

    @rlamorea

    Like @Aladinndevolpment I'm in a catch-22 with the JSON import.

    Using express with javascript.

    Using nodejs 17.3 I get this when I try to start app.js (this is the app.js from the getting started documentation)

    node:internal/errors:464
        ErrorCaptureStackTrace(err);
        ^
    
    TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".json" for /Users/rick/projects/rasi/taxservice/node_modules/adminjs/lib/locale/de/translation.json
        at new NodeError (node:internal/errors:371:5)
        at Object.file: (node:internal/modules/esm/get_format:72:15)
        at defaultGetFormat (node:internal/modules/esm/get_format:85:38)
        at defaultLoad (node:internal/modules/esm/load:22:14)
        at ESMLoader.load (node:internal/modules/esm/loader:359:26)
        at ESMLoader.moduleProvider (node:internal/modules/esm/loader:280:58)
        at new ModuleJob (node:internal/modules/esm/module_job:66:26)
        at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:297:17)
        at ESMLoader.getModuleJob (node:internal/modules/esm/loader:261:34)
        at async ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:81:21) {
      code: 'ERR_UNKNOWN_FILE_EXTENSION'
    }
    
    Node.js v17.3.0
    

    If I try to go back to an earlier nodejs (e.g. 16.13) it fails on the assert (which requires 17+).

    I'm two pages into the getting started tutorial and completely blocked.

    Node v17.3 might not work, but Node v18.17 does!
  23. SOULPWRD commented on Oct 26, 2023

    @SOULPWRD

    @mickyarun If you use @adminjs/bundler, did you set assetsCDN in AdminJS object?

    @SOULPWRD is an entry file generated in .adminjs folder when you start the server?

    Hi, yes it is.

    AdminJS.UserComponents = {}
    

    Sorry for a late reply. I was waiting until the version 7 gets a bit stable. Unfortunately, the problem still persists.

  24. varshiludani commented on Nov 14, 2023

    @varshiludani

    Hi @dziraf, I'm facing issues with deleting rows with Hapi and TypeORM. Just created a new project and tried again.

  25. wtime commented on Nov 17, 2023

    @wtime

    Hi,
    something is wrong with the nested translations
    i18next::translator: missingKey pl translation properties.isActive.true Yes
    I have this key in my translations:
    image
    The column header in the table translates correctly, but the translation in the records is missing:
    image

    Having either the property translation or the nested properties (like *.true/*.false) works fine. It only breaks once you have both, and always seems to pick the resource ove the nested ones.

    That's right, in an earlier version of AdminJs (6.*) this worked fine

    Seems to be because V06 just got the admin.locales and initialized the redux but V07 does a flatten+unflatten on the locales, so this *.true, *.false etc is now broken.

    Hey @dziraf do you have in mind when you will be able to fix this issue?

  26. asta-nguyen commented on Dec 21, 2023

    @asta-nguyen
    Contributor

    Hi, guys cc @dziraf, I faced an issue with filter UI on action list resources.
    I'm following the document https://docs.adminjs.co/basics/resource#changing-default-navigation-link to add filter for resource such as my code below:

    export const userResource: ResourceWithOptions = {
      resource: UserModel,
      options: {
        id: 'users',
        navigation: {
          icon: 'Users',
        },
        href: ({ h, resource }) => {
          return h.resourceActionUrl({
            resourceId: resource.decorate().id(),
            actionName: 'list',
            search: `?filters.role=User`,
          });
        },

    and I faced an issue with the UI. It looks like:

    Screenshot 2023-12-21 at 09 05 26

    The filter drawer section display below the table (broken UI)
    Please let me know any suggestions to fix this issue. Thank guys.

    my versions:

      "dependencies": {
        "@adminjs/bundler": "^3.0.0",
        "@adminjs/express": "^6.0.1",
        "@adminjs/mongoose": "^4.0.0",
        "@adminjs/themes": "^1.0.1",
        "mongoose": "^7.4.0",
         "adminjs": "^7.4.2",
        }
  27. hieupham1203 commented on Jan 11, 2024

    @hieupham1203

    Hi, I see adminjs/mongoose is using MongooseModel.count, but this function is deprecated. I got error. Please check and update.

    image image image
  28. rushg171 commented on Jan 13, 2024

    @rushg171

    Same here! MongooseModel.count() is deprecated! Will it be fixed in the next version?

  29. jakapurg commented on Jan 25, 2024

    @jakapurg

    Hey guys, a minor issue I found while adding filters on page navigation.

    The following two options act differently.

    options: {
                        href: () => undefined,
                        href: undefined
    }
    
    

    The first one hides the resource from the navigation, but it is still acccessible via URL, while the second correctly shows the resource in navigation.

  30. prsws commented on Sep 10, 2024

    @prsws

    Is there a simple way to use buildAuthenticatedRouter (express) using 'username' instead of 'email' as the required parameter? I noticed it's coded in types.ts but it's difficult to replace 'authenticate' (AuthenticationOptions) in practice (app.ts). The reason is that in my application a person can reuse its email address (e.g. as staff with multiple roles, as a tenant with multiple shops, or a customer doing business with different tenants) but is always constrained to a distinct username in each instance. So far AdminJS is great, thanks!

  31. bmbaron commented on Feb 4, 2025

    @bmbaron

    @Aladinndevolpment Looks like type assertions are supported from Node 17+

    I'm having this problem with Node version 23.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions