Webpack "UnhandledSchemeError ... node:" protocol import in CI
A module imports a Node built-in using the node: URI scheme (for example node:fs). Webpack does not resolve that scheme out of the box, so it raises UnhandledSchemeError during the build.
What this error means
The build fails with "UnhandledSchemeError: Reading from 'node:fs' is not handled by plugins (Unhandled scheme)" and a note that Webpack supports data:, file: and http(s): by default.
Module build failed: UnhandledSchemeError: Reading from "node:buffer" is not
handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.Common causes
A dependency uses node: prefixed imports
Newer packages import core modules as node:fs or node:buffer; older Webpack 5 minors do not resolve that scheme.
A browser target pulling in Node built-ins
Bundling Node-only code for the web surfaces the scheme because there is no browser equivalent to map it to.
How to fix it
Upgrade Webpack so it resolves node:
Recent Webpack 5 versions handle the node: scheme for server targets. Upgrade to a version that supports it.
npm install webpack@latest
npx webpack --versionMap node: imports with a NormalModuleReplacementPlugin
For a browser build, strip the prefix or point the import at a polyfill so Webpack can resolve it.
new webpack.NormalModuleReplacementPlugin(
/^node:/,
(resource) => { resource.request = resource.request.replace(/^node:/, ''); }
)How to prevent it
- Keep Webpack current so new URI schemes are supported.
- Target the right platform so Node built-ins are not bundled for the browser.
- Audit dependencies that switched to node: prefixed imports.