Skip to content

Commit 5bc6139

Browse files
committed
fix(npm): add Node.js >= 22 version guard to npm bundle
Users installing via pnpm (or npm/yarn without strict engine enforcement) on Node.js < 22 got a cryptic `ERR_UNKNOWN_BUILTIN_MODULE: node:sqlite` crash at startup because the bun:sqlite polyfill depends on the `node:sqlite` built-in which only exists in Node.js 22+. Add a version check to the esbuild bundle banner so it runs before any require() calls. On Node < 22 users now see a clear error with install instructions for the standalone binary instead of a V8 internals crash.
1 parent 233fa6c commit 5bc6139

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

script/bundle.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ const result = await build({
9494
"@sentry/bun": "@sentry/node",
9595
},
9696
banner: {
97-
// Suppress Node.js warnings (e.g., SQLite experimental) - not useful for CLI users
97+
// Check Node.js version (>= 22 required for node:sqlite) and suppress warnings
9898
js: `#!/usr/bin/env node
99+
if(parseInt(process.versions.node)<22){console.error("Error: sentry requires Node.js 22 or later (found "+process.version+").\n\nEither upgrade Node.js, or install the standalone binary instead:\n curl -fsSL https://cli.sentry.dev/install | bash\n");process.exit(1)}
99100
{let e=process.emit;process.emit=function(n,...a){return n==="warning"?!1:e.apply(this,[n,...a])}}`,
100101
},
101102
sourcemap: true,

0 commit comments

Comments
 (0)