From 77412b89fabe132e4384297e0b9bcce806abc8d2 Mon Sep 17 00:00:00 2001 From: Haozhe Date: Thu, 25 Jun 2026 19:21:17 +0800 Subject: [PATCH] fix(server): import bcryptjs via default export for ESM dev runner (#1104) - bcryptjs is a CommonJS package whose index.js re-exports via `module.exports = require("./dist/bcrypt.js")` - Node's cjs-module-lexer cannot detect named exports through that require() indirection, so `import { compare, hash } from 'bcryptjs'` threw "Named export 'compare' not found" under the tsx dev runner (make dev), even though vitest and the esbuild bundle handled it fine - switch to the default import and destructure, which works across tsx, vitest and the bundled binary --- packages/server/src/services/auth/password.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/server/src/services/auth/password.ts b/packages/server/src/services/auth/password.ts index 0a60f8bec..14abc3641 100644 --- a/packages/server/src/services/auth/password.ts +++ b/packages/server/src/services/auth/password.ts @@ -1,4 +1,6 @@ -import { compare, hash } from 'bcryptjs'; +import bcrypt from 'bcryptjs'; + +const { compare, hash } = bcrypt; const BCRYPT_COST = 12;