NestJS app hangs on startup after upgrading Better Auth from 1.3.9+

I’m running into an issue when upgrading Better Auth in a NestJS API. Current working version: 1.3.8 Issue starts happening from: 1.3.9 (including 1.3.10-beta.1) When I try to start the API, it just hangs and the terminal stays stuck on this:
[11:10:36 PM] File change detected. Starting incremental compilation...
[11:10:36 PM] Found 0 errors. Watching for file changes.
[11:10:36 PM] File change detected. Starting incremental compilation...
[11:10:36 PM] Found 0 errors. Watching for file changes.
The app never actually boots up. I already tried deleting node_modules, dist, pnpm-lock.yaml, etc., but nothing fixes it. It seems like something introduced in 1.3.9 might have broken compatibility with NestJS. Is anyone else experiencing this? Or is there something I might be missing in the migration?
5 Replies
bekacru
bekacru4w ago
does the previous version works?
braga
bragaOP4w ago
yes on 1.3.8 version work well After multiple attempts, including deleting node_modules and pnpm-lock.yaml and forcing a reinstall, I’m now encountering the following error on versions 1.3.9 and above.
node_modules\.pnpm\better-auth@1.3.10-beta.1_n_304d37530b188ee7fd19476524251756\node_modules\better-auth\dist\crypto\index.cjs:4
const chacha_js = require('@noble/ciphers/chacha.js');
^

Error [ERR_REQUIRE_ESM]: require() of ES Module \node_modules\.pnpm\@noble+ciphers@2.0.0\node_modules\@noble\ciphers\chacha.js from \node_modules\.pnpm\better-auth@1.3.10-beta.1_n_304d37530b188ee7fd19476524251756\node_modules\better-auth\dist\crypto\index.cjs not supported.
Instead change the require of chacha.js in \node_modules\.pnpm\better-auth@1.3.10-beta.1_n_304d37530b188ee7fd19476524251756\node_modules\better-auth\dist\crypto\index.cjs to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (\node_modules\.pnpm\better-auth@1.3.10-beta.1_n_304d37530b188ee7fd19476524251756\node_modules\better-auth\dist\crypto\index.cjs:4:19)
at Object.<anonymous> (node_modules\.pnpm\better-auth@1.3.10-beta.1_n_304d37530b188ee7fd19476524251756\node_modules\better-auth\dist\shared\better-auth.DOyRFR4S.cjs:9:22)
at Object.<anonymous> (\node_modules\.pnpm\better-auth@1.3.10-beta.1_n_304d37530b188ee7fd19476524251756\node_modules\better-auth\dist\api\index.cjs:4:31)
at Object.<anonymous> (\node_modules\.pnpm\@thallesp+nestjs-better-aut_18e76e4d758477022566f6651b77f6e5\node_modules\@thallesp\nestjs-better-auth\dist\index.js:116:18)
at Object.<anonymous> (\apps\api\dist\app.module.js:11:30)
at Object.<anonymous> (\apps\api\dist\main.js:5:22) {
code: 'ERR_REQUIRE_ESM'
}

Node.js v20.9.0
node_modules\.pnpm\better-auth@1.3.10-beta.1_n_304d37530b188ee7fd19476524251756\node_modules\better-auth\dist\crypto\index.cjs:4
const chacha_js = require('@noble/ciphers/chacha.js');
^

Error [ERR_REQUIRE_ESM]: require() of ES Module \node_modules\.pnpm\@noble+ciphers@2.0.0\node_modules\@noble\ciphers\chacha.js from \node_modules\.pnpm\better-auth@1.3.10-beta.1_n_304d37530b188ee7fd19476524251756\node_modules\better-auth\dist\crypto\index.cjs not supported.
Instead change the require of chacha.js in \node_modules\.pnpm\better-auth@1.3.10-beta.1_n_304d37530b188ee7fd19476524251756\node_modules\better-auth\dist\crypto\index.cjs to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (\node_modules\.pnpm\better-auth@1.3.10-beta.1_n_304d37530b188ee7fd19476524251756\node_modules\better-auth\dist\crypto\index.cjs:4:19)
at Object.<anonymous> (node_modules\.pnpm\better-auth@1.3.10-beta.1_n_304d37530b188ee7fd19476524251756\node_modules\better-auth\dist\shared\better-auth.DOyRFR4S.cjs:9:22)
at Object.<anonymous> (\node_modules\.pnpm\better-auth@1.3.10-beta.1_n_304d37530b188ee7fd19476524251756\node_modules\better-auth\dist\api\index.cjs:4:31)
at Object.<anonymous> (\node_modules\.pnpm\@thallesp+nestjs-better-aut_18e76e4d758477022566f6651b77f6e5\node_modules\@thallesp\nestjs-better-auth\dist\index.js:116:18)
at Object.<anonymous> (\apps\api\dist\app.module.js:11:30)
at Object.<anonymous> (\apps\api\dist\main.js:5:22) {
code: 'ERR_REQUIRE_ESM'
}

Node.js v20.9.0
Even when I clone my project from scratch and try to start my API, I get the error mentioned above.
bekacru
bekacru4w ago
noble is now esm only and we updated to latest version I think that's what broke it can you udpate your node version to v20.19+
braga
bragaOP4w ago
This solved my problem, thank you very much, and sorry for bothering you with something so silly.
electrode
electrode2w ago
Found your question online and asked 22h ago, thank you very much! I was able to resolve mine too by switch node version.

Did you find this page helpful?