You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
这个包的路径是})
module "/Users/xxxxx/Desktop/tank/shadcn-admin/node_modules/better-auth/dist/client/plugins/index",他是在服务端的。但我需要引入他 按照官方文档 然后就会报错
$ vite
VITE v7.2.2 ready in 323 ms
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ press h + enter to show help
^C
❯
❯
❯ bun dev
$ concurrently "bun client" "bun server"
[0] $ cd client && bun dev
[1] $ bun run --hot server/index.ts
[0] $ vite
[1] Started development server: http://localhost:3000
[0]
[0] VITE v7.2.2 ready in 150 ms
[0]
[0] ➜ Local: http://localhost:5173/
[0] ➜ Network: use --host to expose
[0] ✘ [ERROR] Could not resolve "react"
[0]
[0] ../node_modules/better-auth/dist/client/react/index.mjs:3:58:
[0] 3 │ import { useRef, useCallback, useSyncExternalStore } from 'react';
[0] ╵ ~~~~~~~
[0]
[0] You can mark the path "react" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.
[0]
[0] 14:07:20 [vite] (client) error while updating dependencies:
[0] Error: Error during dependency optimization:
[0]
[0] ✘ [ERROR] Could not resolve "react"
[0]
[0] ../node_modules/better-auth/dist/client/react/index.mjs:3:58:
[0] 3 │ import { useRef, useCallback, useSyncExternalStore } from 'react';
[0] ╵ ~~~~~~~
[0]
[0] You can mark the path "react" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.
[0]
[0]
[0] at failureErrorWithLog (/Users/binlee/Desktop/tank/shadcn-admin/client/node_modules/esbuild/lib/main.js:1467:15)
[0] at /Users/binlee/Desktop/tank/shadcn-admin/client/node_modules/esbuild/lib/main.js:926:25
[0] at /Users/binlee/Desktop/tank/shadcn-admin/client/node_modules/esbuild/lib/main.js:1345:9
[0] at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
This discussion was converted from issue #21115 on November 14, 2025 04:18.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
我使用hono better-auth 构建了一个server 使用vite react构建了client 当我想使用better-auth中的客户端方法 import { createAuthClient } from 'better-auth/react'
import { adminClient } from 'better-auth/client/plugins'
export const authClient = createAuthClient({
plugins: [adminClient()],
})
这个包的路径是})
module "/Users/xxxxx/Desktop/tank/shadcn-admin/node_modules/better-auth/dist/client/plugins/index",他是在服务端的。但我需要引入他 按照官方文档 然后就会报错
$ vite
VITE v7.2.2 ready in 323 ms
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ press h + enter to show help
^C
❯
❯
❯ bun dev
$ concurrently "bun client" "bun server"
[0] $ cd client && bun dev
[1] $ bun run --hot server/index.ts
[0] $ vite
[1] Started development server: http://localhost:3000
[0]
[0] VITE v7.2.2 ready in 150 ms
[0]
[0] ➜ Local: http://localhost:5173/
[0] ➜ Network: use --host to expose
[0] ✘ [ERROR] Could not resolve "react"
[0]
[0] ../node_modules/better-auth/dist/client/react/index.mjs:3:58:
[0] 3 │ import { useRef, useCallback, useSyncExternalStore } from 'react';
[0] ╵ ~~~~~~~
[0]
[0] You can mark the path "react" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.
[0]
[0] 14:07:20 [vite] (client) error while updating dependencies:
[0] Error: Error during dependency optimization:
[0]
[0] ✘ [ERROR] Could not resolve "react"
[0]
[0] ../node_modules/better-auth/dist/client/react/index.mjs:3:58:
[0] 3 │ import { useRef, useCallback, useSyncExternalStore } from 'react';
[0] ╵ ~~~~~~~
[0]
[0] You can mark the path "react" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.
[0]
[0]
[0] at failureErrorWithLog (/Users/binlee/Desktop/tank/shadcn-admin/client/node_modules/esbuild/lib/main.js:1467:15)
[0] at /Users/binlee/Desktop/tank/shadcn-admin/client/node_modules/esbuild/lib/main.js:926:25
[0] at /Users/binlee/Desktop/tank/shadcn-admin/client/node_modules/esbuild/lib/main.js:1345:9
[0] at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
我的前端环境如下{
"name": "client",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"react": "^19.2.0",
"react-dom": "^19.2.0"
},
"devDependencies": {
"@eslint/js": "^9.39.1",
"@types/node": "^24.10.0",
"@types/react": "^19.2.2",
"@types/react-dom": "^19.2.2",
"@vitejs/plugin-react": "^5.1.0",
"eslint": "^9.39.1",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.24",
"globals": "^16.5.0",
"typescript": "~5.9.3",
"typescript-eslint": "^8.46.3",
"vite": "^7.2.2"
}
}
后端环境如下
{
"name": "shadcn-admin",
"scripts": {
"dev": "concurrently "bun client" "bun server"",
"client": "cd client && bun dev",
"server": "bun run --hot server/index.ts",
"db:push": "drizzle-kit push",
"db:generate": "drizzle-kit generate",
"db:migrate": "drizzle-kit migrate",
"db:studio": "drizzle-kit studio"
},
"dependencies": {
"@types/pg": "^8.15.5",
"better-auth": "^1.3.9",
"concurrently": "^9.2.1",
"drizzle-orm": "^0.44.6",
"hono": "^4.10.2",
"pg": "^8.16.3",
"zod": "^4.1.12"
},
"devDependencies": {
"@types/bun": "latest",
"drizzle-kit": "^0.31.5"
}
}
vite配置如下
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { fileURLToPath } from "node:url";
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
server: {
proxy: {
"/api": {
target: "http://localhost:3000",
changeOrigin: true,
},
},
},
});
这是better-auth的使用文档 我是根据文档的要求进行操作的
https://www.better-auth.com/docs/installation
Reproduction
1
Steps to reproduce
No response
System Info
Used Package Manager
bun
Logs
No response
Validations
Beta Was this translation helpful? Give feedback.
All reactions