[GH-ISSUE #1502] nanostores [ERR_REQUIRE_ESM] #8793

Closed
opened 2026-04-13 04:00:06 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @fvcoder on GitHub (Feb 19, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1502

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. create project with nest new loproda
  2. install better-auth
  3. generate & migrate schema.prisma
  4. run project

Current vs. Expected behavior

var nanostores = require('nanostores');
                 ^

Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\conta\OneDrive\Escritorio\loproda\api\node_modules\nanostores\index.js from C:\Users\conta\OneDrive\Escritorio\loproda\api\node_modules\better-auth\dist\chunk-XAK7GFTD.cjs not supported.
Instead change the require of index.js in C:\Users\conta\OneDrive\Escritorio\loproda\api\node_modules\better-auth\dist\chunk-XAK7GFTD.cjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (C:\Users\conta\OneDrive\Escritorio\loproda\api\node_modules\better-auth\dist\chunk-XAK7GFTD.cjs:6:18) {
  code: 'ERR_REQUIRE_ESM'
}

What version of Better Auth are you using?

1.1.18

Provide environment information

OS: WINDOWS 11

Framework: Nest Js@10.0.0

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

Backend

Auth config (if applicable)

import { Injectable } from "@nestjs/common";
import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { username } from "better-auth/plugins";
import { twoFactor } from "better-auth/plugins";
import { oneTap } from "better-auth/plugins";
import { organization } from "better-auth/plugins";
import { admin } from "better-auth/plugins";
import { oidcProvider } from "better-auth/plugins";
import { multiSession } from "better-auth/plugins";
import { openAPI } from "better-auth/plugins";
import { jwt } from "better-auth/plugins";
import { passkey } from "better-auth/plugins/passkey";
import { PrismaService } from "src/core/service/prisma.service";

@Injectable()
export class AuthService {
  betterAuth: ReturnType<typeof betterAuth>;

  constructor(private readonly prisma: PrismaService) {
    this.betterAuth = betterAuth({
      database: prismaAdapter(this.prisma, {
        provider: "postgresql", // or "mysql", "postgresql", ...etc
      }),
      emailAndPassword: {
        enabled: true,
      },
      plugins: [
        username(),
        twoFactor(),
        passkey(),
        oneTap(),
        organization(),
        admin(),
        oidcProvider({
          loginPage: "/v1/authentication/login",
        }),
        multiSession(),
        openAPI(),
        jwt(),
      ],
    }) as ReturnType<typeof betterAuth>;
  }
}

Additional context

No response

Originally created by @fvcoder on GitHub (Feb 19, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1502 ### Is this suited for github? - [ ] Yes, this is suited for github ### To Reproduce 1. create project with `nest new loproda` 2. install better-auth 3. generate & migrate schema.prisma 4. run project ### Current vs. Expected behavior ``` var nanostores = require('nanostores'); ^ Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\conta\OneDrive\Escritorio\loproda\api\node_modules\nanostores\index.js from C:\Users\conta\OneDrive\Escritorio\loproda\api\node_modules\better-auth\dist\chunk-XAK7GFTD.cjs not supported. Instead change the require of index.js in C:\Users\conta\OneDrive\Escritorio\loproda\api\node_modules\better-auth\dist\chunk-XAK7GFTD.cjs to a dynamic import() which is available in all CommonJS modules. at Object.<anonymous> (C:\Users\conta\OneDrive\Escritorio\loproda\api\node_modules\better-auth\dist\chunk-XAK7GFTD.cjs:6:18) { code: 'ERR_REQUIRE_ESM' } ``` ### What version of Better Auth are you using? 1.1.18 ### Provide environment information ```bash OS: WINDOWS 11 Framework: Nest Js@10.0.0 ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { Injectable } from "@nestjs/common"; import { betterAuth } from "better-auth"; import { prismaAdapter } from "better-auth/adapters/prisma"; import { username } from "better-auth/plugins"; import { twoFactor } from "better-auth/plugins"; import { oneTap } from "better-auth/plugins"; import { organization } from "better-auth/plugins"; import { admin } from "better-auth/plugins"; import { oidcProvider } from "better-auth/plugins"; import { multiSession } from "better-auth/plugins"; import { openAPI } from "better-auth/plugins"; import { jwt } from "better-auth/plugins"; import { passkey } from "better-auth/plugins/passkey"; import { PrismaService } from "src/core/service/prisma.service"; @Injectable() export class AuthService { betterAuth: ReturnType<typeof betterAuth>; constructor(private readonly prisma: PrismaService) { this.betterAuth = betterAuth({ database: prismaAdapter(this.prisma, { provider: "postgresql", // or "mysql", "postgresql", ...etc }), emailAndPassword: { enabled: true, }, plugins: [ username(), twoFactor(), passkey(), oneTap(), organization(), admin(), oidcProvider({ loginPage: "/v1/authentication/login", }), multiSession(), openAPI(), jwt(), ], }) as ReturnType<typeof betterAuth>; } } ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-13 04:00:07 -05:00
Author
Owner

@fvcoder commented on GitHub (Feb 19, 2025):

is caused by the plugin: passkey

import { passkey } from "better-auth/plugins/passkey";

<!-- gh-comment-id:2668984843 --> @fvcoder commented on GitHub (Feb 19, 2025): is caused by the plugin: passkey ```ts import { passkey } from "better-auth/plugins/passkey"; ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#8793