Skip to content
← Back to activity

Public problem

Module build failed: UnhandledSchemeError: Reading from "node:crypto" is not handled by plugins...

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

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.

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

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