defaultStatements and defaultAc have an export problem on my project #1069

Closed
opened 2026-03-13 08:21:15 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @Remy-Beauperin on GitHub (Apr 17, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

In permission.ts : import { adminAc, defaultStatements, memberAc, ownerAc } from "better-auth/plugins";

The server return the error : Export adminAc doesn't exist in target module.

If i remove adminAc the error jump to the "defaultStatements" import.

Current vs. Expected behavior

It seems not found the export in the better-auth/plugins file

But Cursor (or visual code) find the export

What version of Better Auth are you using?

^1.2.4

Provide environment information

Mac OS
Firefox

Which area(s) are affected? (Select all that apply)

Package

Auth config (if applicable)

import { resend } from './resend';
import { nextCookies } from 'better-auth/next-js';
import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { prisma } from './prisma';
import { organization } from "better-auth/plugins"
import { ac, roles } from './permissions';

export const auth = betterAuth({
  database: prismaAdapter(prisma, {
      provider: "postgresql", // or "mysql", "postgresql", ...etc
  }),
  emailAndPassword: {
      enabled: true,
  },
  // socialProviders: {
  //     google: {
  //         clientId: process.env.GOOGLE_CLIENT_ID,
  //         clientSecret: process.env.GOOGLE_CLIENT_SECRET
  //     },
  //     github: {
  //         clientId: process.env.GITHUB_CLIENT_ID,
  //         clientSecret: process.env.GITHUB_CLIENT_SECRET
  //     }
  // },
  plugins: [
    organization({
      ac,
      roles: roles,
    }),
    nextCookies()
  ]
});

Additional context

I also try with { defaultRoles } but same things. I try to update my packages without success.

Here it is the permission file :

import { createAccessControl } from "better-auth/plugins/access";
import { defaultRoles } from "better-auth/plugins";
 
const statement = {
    project: ["create", "share", "update", "delete"],
} as const;
 
const ac = createAccessControl(statement);
 
const customer = ac.newRole({ 
  project: ["create", "update", "delete"],
}); 

export const roles = {
  ...defaultRoles,
  customer,
}

export { ac }
Originally created by @Remy-Beauperin on GitHub (Apr 17, 2025). ### Is this suited for github? - [ ] Yes, this is suited for github ### To Reproduce In permission.ts : import { adminAc, defaultStatements, memberAc, ownerAc } from "better-auth/plugins"; The server return the error : Export adminAc doesn't exist in target module. If i remove adminAc the error jump to the "defaultStatements" import. ### Current vs. Expected behavior It seems not found the export in the better-auth/plugins file But Cursor (or visual code) find the export ### What version of Better Auth are you using? ^1.2.4 ### Provide environment information ```bash Mac OS Firefox ``` ### Which area(s) are affected? (Select all that apply) Package ### Auth config (if applicable) ```typescript import { resend } from './resend'; import { nextCookies } from 'better-auth/next-js'; import { betterAuth } from "better-auth"; import { prismaAdapter } from "better-auth/adapters/prisma"; import { prisma } from './prisma'; import { organization } from "better-auth/plugins" import { ac, roles } from './permissions'; export const auth = betterAuth({ database: prismaAdapter(prisma, { provider: "postgresql", // or "mysql", "postgresql", ...etc }), emailAndPassword: { enabled: true, }, // socialProviders: { // google: { // clientId: process.env.GOOGLE_CLIENT_ID, // clientSecret: process.env.GOOGLE_CLIENT_SECRET // }, // github: { // clientId: process.env.GITHUB_CLIENT_ID, // clientSecret: process.env.GITHUB_CLIENT_SECRET // } // }, plugins: [ organization({ ac, roles: roles, }), nextCookies() ] }); ``` ### Additional context I also try with { defaultRoles } but same things. I try to update my packages without success. Here it is the permission file : ``` import { createAccessControl } from "better-auth/plugins/access"; import { defaultRoles } from "better-auth/plugins"; const statement = { project: ["create", "share", "update", "delete"], } as const; const ac = createAccessControl(statement); const customer = ac.newRole({ project: ["create", "update", "delete"], }); export const roles = { ...defaultRoles, customer, } export { ac } ```
Author
Owner

@Kinfe123 commented on GitHub (Apr 18, 2025):

Can you try deleting the node_module and reinstalling it again

@Kinfe123 commented on GitHub (Apr 18, 2025): Can you try deleting the node_module and reinstalling it again
Author
Owner

@Remy-Beauperin commented on GitHub (Apr 18, 2025):

Yes of course !
It's done but don't fix the issue... :

Image

@Remy-Beauperin commented on GitHub (Apr 18, 2025): Yes of course ! It's done but don't fix the issue... : ![Image](https://github.com/user-attachments/assets/e80ec26e-e37f-4c74-a967-2236cb086cd7)
Author
Owner

@Kinfe123 commented on GitHub (Apr 18, 2025):

It is not imported from /plugin make sure to add /organization/access at the end

@Kinfe123 commented on GitHub (Apr 18, 2025): It is not imported from /plugin make sure to add /organization/access at the end
Author
Owner

@Remy-Beauperin commented on GitHub (Apr 18, 2025):

Wow ! Thanks for that ! It's work fine !
After that i see on the doc that there was the good acces directory. I think (hope) you have changed something otherwise I have not good eyes...

Thanks for your time
Have a nice day

@Remy-Beauperin commented on GitHub (Apr 18, 2025): Wow ! Thanks for that ! It's work fine ! After that i see on the doc that there was the good acces directory. I think (hope) you have changed something otherwise I have not good eyes... Thanks for your time Have a nice day
Author
Owner

@lucafaggianelli commented on GitHub (Jul 16, 2025):

@Kinfe123 I faced the same problem for adminAc and defaultStatements, they should be imported from better-auth/plugins/admin/access rather than better-auth/plugins:

import { adminAc, defaultStatements } from 'better-auth/plugins/admin/access'

Though the documentation for those is referencing the wrong import, also I think this should be fixed at TypeScript level as well, as TypeScript doesn't complain about the import issue. I can open another issue if you want

@lucafaggianelli commented on GitHub (Jul 16, 2025): @Kinfe123 I faced the same problem for `adminAc` and `defaultStatements`, they should be imported from `better-auth/plugins/admin/access` rather than `better-auth/plugins`: ``` import { adminAc, defaultStatements } from 'better-auth/plugins/admin/access' ``` Though the documentation for those is referencing the wrong import, also I think this should be fixed at TypeScript level as well, as TypeScript doesn't complain about the import issue. I can open another issue if you want
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1069