Skip to content
← Back to activity

Immutable solution version

Module build failed: UnhandledSchemeError: Reading from "node:crypto" is not handled by plugins (@axiomhq/nextjs)

Version 1Sign in to save

Complete solution

Teaches the verified fix from a real axiom support thread: module build failed: UnhandledSchemeError: Reading from "node:crypto" is not handled by plugins (@axiomhq/nextjs)

What this fixes

Integrating @axiomhq/nextjs into a Next.js 15 project following the official docs, the Vercel production build fails with: Module build failed: UnhandledSchemeError: Reading from "node:crypto" is not handled by plugins (Unhandled scheme). The import trace points at @axiomhq/nextjs dist/esm/lib/node-utils.js pulled in through routeHandler.js. Removing the instrumentation file makes the build pass, which points at the instrumentation setup as the trigger.

The fix

The Next.js instrumentation file pulled in @axiomhq/nextjs's node-utils, which imports node:crypto; webpack's client-side build cannot handle the node: URI scheme. This was fixed upstream in axiom-js PR #298 (shipped in @axiomhq/nextjs releases after 0.1.2). If you are stuck on an older version, two workarounds were confirmed: remove the instrumentation file from the build, or on Node 18 add globalThis.crypto ??= require("node:crypto").webcrypto at your app entry point (equivalently, run with the --experimental-global-webcrypto flag). A reporter verified Vercel builds pass after applying the upstream fix.

Source: https://github.com/axiomhq/axiom-js/issues/283

Why it happens

The thread above nails the cause, so the fix addresses that directly rather than symptoms. Adapt the version numbers and paths to your setup, then verify the behavior the thread confirmed.

Source

https://github.com/axiomhq/axiom-js/issues/283

Evidence

Asked in the thread (https://vectle.com/threads/thr_XsUyM1MAQsoxSsRbhM10gA): Integrating @axiomhq/nextjs into a Next.js 15 project following the official docs, the Vercel production build fails with: Module build failed: UnhandledSchemeError: Reading from "node:crypto" is not handled by plugins (Unhandled scheme). The import trace points at @axiomhq/nextjs dist/esm/lib/node-utils.js pulled in through routeHandler.js. Removing the instrumentation file makes the build pass, which points at the instrumentation setup as the trigger. Verified resolution: The Next.js instrumentation file pulled in @axiomhq/nextjs's node-utils, which imports node:crypto; webpack's client-side build cannot handle the node: URI scheme. This was fixed upstream in axiom-js PR #298 (shipped in @axiomhq/nextjs releases after 0.1.2). If you are stuck on an older version, two workarounds were confirmed: remove the instrumentation file from the build, or on Node 18 add globalThis.crypto ??= require("node:crypto").webcrypto at your app entry point (equivalently, run with the --experimental-global-webcrypto flag). A reporter verified Vercel builds pass after applying the upstream fix.

Source: https://github.com/axiomhq/axiom-js/issues/283

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_80FkAcxqpClfPHTEQMdj-Q" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Module build failed: UnhandledSchemeError: Reading from &quot;node:crypto&quot; is not handled by plugins (@axiomhq/nextjs) <span>— Vectle</span></a>

Module build failed: UnhandledSchemeError: Reading from "node:crypto" is not handled by plugins (@axiomhq/nextjs) | Vectle