All guides (in French)Lire en français
Deploy4 min read

The “export named 'styleText'” error

The message talks about a missing export in an internal Node module and never says the word “version”. Yet that is the whole story: your project is being built by a Node older than the one Vite requires. Here is the version to target, and why the first one that makes this message go away is not the right one.

What this guide proves

  • The same Vite 8 project built under six Node versions, with the result of each.
  • The version at which the message disappears, and the one at which the build actually succeeds.
  • The same error reproduced with MCP Inspector, and the Node version that clears it.

The message

$ npm ci && npx vite build, on Node 18.20.5
file:///app/node_modules/rolldown/dist/shared/create-bundler-option-DJpvtSqr.mjs:8
import { formatWithOptions, styleText } from "node:util";
                            ^^^^^^^^^
SyntaxError: The requested module 'node:util' does not provide an export named 'styleText'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:191:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:337:24)

Node.js v18.20.5
Actual output, in a node:18.20.5 container (linux/amd64), on 23 September 2026.

styleText is a Node function that colours text in the terminal. It only exists from Node 20.12 and 21.7. Vite 8 and its bundler, rolldown, import it as soon as they load: on an older Node, the import fails before the build even starts.

If you see this message, your project is not the problem. The Node version that builds it, on your machine, in your CI or at your host, is too old.

Version by version

The trap is to upgrade just enough to make the message disappear. We built the same project under six Node versions, changing nothing else.

NodestyleText existsvite build result
18.20.5nofails: export named 'styleText'
20.11.1nofails: export named 'styleText'
20.12.0yesfails: Cannot find native binding
20.18.1yesfails: Cannot find native binding
22.11.0yesfails: Cannot find native binding
22.12.0yesbuilt in 837 ms
Method. A Vite 8.3.0 project (rolldown 1.2.9), lockfile generated on a Mac. For each version: official node:<version> Docker image on linux/amd64, npm ci then npx vite build. Whether styleText exists is read with import("node:util"). Measured from linux/amd64 Docker containers, on 23 September 2026.

Between Node 20.12 and 22.11, styleText exists and the message goes away. But the build fails right after on another error, “Cannot find native binding”, which blames npm and has nothing to do with it. Vite 8’s real requirement is higher: ^20.19.0 || >=22.12.0. That is the threshold to aim for, not the styleText one.

The same error in MCP Inspector

The MCP Inspector, the tool used to test a Model Context Protocol server, ships its interface with Vite. Started from an older Node, it stops on the same import, worded slightly differently.

$ npx -y @modelcontextprotocol/inspector, on Node 20.11.1
Error running MCP Inspector: The requested module 'node:util' does not provide an export named 'styleText'
Actual output, in a node:20.11.1 container (linux/amd64), on 21 October 2026.

The current Inspector declares "node": ">=22.19.0". On Node 22.19 it starts normally. The fix is the same as for Vite: upgrade Node, not the project.

Do not be fooled if it works on an even older Node. On Node 18.20 (npm 10.8), npx quietly installed Inspector 0.15.0, an old release with no Node requirement, and it started. On Node 20.11 (npm 10.2), it took the latest release and crashed. You get a working tool or an error depending on your npm, not on your project.

The fix

Declare the version in the project itself. Vercel, Netlify and Nixpacks read at least one of these two files, and the declaration travels with the code instead of depending on a setting forgotten in a dashboard.

package.json
{
  "engines": {
    "node": ">=22.12"
  }
}
At least 22.12, not just “22”: some environments still serve 22.11.
.nvmrc
22
Read by nvm locally and by Netlify, which take the latest 22, and by Nixpacks, which only keeps the major number.

On your machine, nvm install 22 then nvm use 22 install the latest 22. On Vercel, the version can also be set in the project settings, under Build and Deployment; on Netlify, with the NODE_VERSION variable. Either way, package.json remains the safest declaration.

Sources

  1. [1]Node.js documentation, util.styleText, the function was added in v21.7.0 and v20.12.0.
  2. [2]The package.json of Vite 8.3.0, engines field: ^20.19.0 || >=22.12.0. Same requirement for rolldown 1.2.9 and its native binaries.
  3. [3]The package.json of @modelcontextprotocol/inspector 2.11.0, engines field: >=22.19.0.
  4. [4]Our tests, official Docker images node:18.20.5, 20.11.1, 20.12.0, 20.18.1, 22.11.0 and 22.12.0 on 23 September 2026; MCP Inspector on node:18.20.5, 20.11.1, 22.12.0 and 22.19.0 on 21 October 2026.

Your project online. Hosted in Switzerland.

A repository, an archive or a site already online. We detect it, build it and put it online over HTTPS. 30 days free.