Adminjs ComponentLoader not found

777 Views Asked by At

I have been trying to make custom component in Adminjs 6.6.5 dashboard but Adminjs ComponentLoader not found error occurs. then i have tried to

import AdminJS from 'adminjs'
const {ComponentLoader} = AdminJS

but i get: Trying to bundle file 'file:/Users/Josip/WebstormProjects/ferry-backend/components/dashboard.jsx' but it doesn't exist

I would really appreciate help...

enter image description here

admin/index.js

import {ComponentLoader} from "adminjs";

const componentLoader = new ComponentLoader()

const Components = {
    MyDashboard: componentLoader.override('Dashboard','../components/dashboard.jsx')
}

export { componentLoader, Components }

index.js

import {componentLoader, Components} from "./admin/index.js";
AdminJS.registerAdapter(AdminJSSequelize)
const admin = new AdminJS({
    databases: [],
    rootPath: '/admin',
    resources:[UsersResources, GuestResources, SalesResources, FinancesResources],
    components:{
          edit: Components.MyDashboard
         },
    componentLoader


})
1

There are 1 best solutions below

0
On

i fixed this problem. You need to do the import as follows

import AdminJs from 'adminjs';
// And now you can use any adminjs dependencies as follows
AdminJs.ValidationError(errors)

My usage example:

if(Object.keys(errors).length) {throw new AdminJs.ValidationError(errors)} else {...}

Good luck with your development!