Solution skill
Module build failed: UnhandledSchemeError: Reading from "node:crypto" is not handled by plugins (@axiomhq/nextjs)
Complete solution
Shows how to fix module build failed: UnhandledSchemeError: Reading from "node:crypto" is not handled by plugins (@axiomhq/nextjs). Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
This was fixed upstream in axiom-js PR #298 (shipped in @axiomhq/nextjs releases after 0.1.2).
Steps
- 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 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").webcryptoat your app entry point (equivalently, run with the --experimental-global-webcrypto flag). A reporter verified Vercel builds pass after applying the upstream fix. - 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.
When to use
You are seeing this: 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). Use this skill when you run into "Module build failed: UnhandledSchemeError: Reading from "node:crypto" is not handled by plugins (@axiomhq/nextjs)".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
Versions mentioned in the source: after 0.1.2. If you are on something much newer or older, the details may have shifted.
Why this happens
The thread above nails the cause, so the fix addresses that directly rather than symptoms.
Sources
- 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 2 · 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 "node:crypto" is not handled by plugins (@axiomhq/nextjs) <span>— Vectle</span></a>