Describe the bug
Running vpr <script> in a project pinned to a Node.js version that does not yet have util.styleText (added in Node 20.12 / 22) crashes at module load time, before any of vp's own engine-compatibility checks can run:
file:///~/.vite-plus/0.2.1/node_modules/.pnpm/vite-plus@0.2.1_vite@8.0.16/node_modules/vite-plus/dist/terminal-uTv0ZaMr.js:2
import { styleText } from "node:util";
^^^^^^^^^
SyntaxError: The requested module 'node:util' does not provide an export named 'styleText'
at ModuleJob._instantiate (internal/modules/esm/module_job.js:98:21)
at async ModuleJob.run (internal/modules/esm/module_job.js:143:5)
at async Loader.import (internal/modules/esm/loader.js:165:24)
at async Object.loadESM (internal/process/esm_loader.js:68:5)
Source:
// vite-plus/dist/terminal-uTv0ZaMr.js
import { styleText } from "node:util";
styleText was added in Node 20.12 and only stabilized in v22, so any project whose .node-version resolves to Node 14 / 16 / 18.x < 20.12 will hit this SyntaxError during ESM instantiation of the terminal helper — i.e. before vp's own "Node.js X is incompatible with Vite+ CLI" message has a chance to fire, and before the script-runner soft-fallback work tracked in #1875 (PR #1865 / #1874) can take effect.
This makes vpr completely unusable in older repos even as a thin script forwarder, which is exactly the use case #1875 was supposed to preserve.
Suggested fix
Either:
- Avoid the static
import { styleText } from "node:util" in any module that can be loaded before the engine check (in particular terminal-*.js, which the CLI bootstrap pulls in eagerly). A small pc-style fallback or a dynamic import gated on process.versions.node >= 20.12 would let the runner reach the vpr soft-fallback path; or
- Build the CLI bootstrap chunk with a downlevel target so static imports don't reference Node-22-only named exports.
Reproduction
Any project with a .node-version pinning Node ≤ 20.11 (reproduced on 14.15.0). Steps:
- In a directory with
.node-version containing 14.15.0 (or use vp env use 14.15.0).
vpr dev (or any vpr <script> — fails before reaching the script).
Result: the SyntaxError above. Expected: the soft-fallback behavior from #1875, or at minimum the previous "Node.js X is incompatible with Vite+ CLI" diagnostic.
Steps to reproduce
echo 14.15.0 > .node-version
vpr dev
System Info
$ vp env current
VITE+ - The Unified Toolchain for the Web
Environment:
Version 14.15.0
Source .node-version
Source Path /home/<me>/<project>/.node-version
Project Root /home/<me>/<project>
Tool Paths:
node ~/.vite-plus/js_runtime/node/14.15.0/bin/node
npm ~/.vite-plus/js_runtime/node/14.15.0/bin/npm
npx ~/.vite-plus/js_runtime/node/14.15.0/bin/npx
$ vp --version
VITE+ - The Unified Toolchain for the Web
vp v0.2.1
Local vite-plus:
vite-plus Not found
Environment:
Package manager npm latest
Node.js v14.15.0 (.node-version)
Used Package Manager
npm
Related
Validations
Describe the bug
Running
vpr <script>in a project pinned to a Node.js version that does not yet haveutil.styleText(added in Node 20.12 / 22) crashes at module load time, before any of vp's own engine-compatibility checks can run:Source:
styleTextwas added in Node 20.12 and only stabilized in v22, so any project whose.node-versionresolves to Node 14 / 16 / 18.x < 20.12 will hit thisSyntaxErrorduring ESM instantiation of the terminal helper — i.e. before vp's own "Node.js X is incompatible with Vite+ CLI" message has a chance to fire, and before the script-runner soft-fallback work tracked in #1875 (PR #1865 / #1874) can take effect.This makes
vprcompletely unusable in older repos even as a thin script forwarder, which is exactly the use case #1875 was supposed to preserve.Suggested fix
Either:
import { styleText } from "node:util"in any module that can be loaded before the engine check (in particularterminal-*.js, which the CLI bootstrap pulls in eagerly). A smallpc-style fallback or a dynamic import gated onprocess.versions.node >= 20.12would let the runner reach thevprsoft-fallback path; orReproduction
Any project with a
.node-versionpinning Node ≤ 20.11 (reproduced on 14.15.0). Steps:.node-versioncontaining14.15.0(or usevp env use 14.15.0).vpr dev(or anyvpr <script>— fails before reaching the script).Result: the
SyntaxErrorabove. Expected: the soft-fallback behavior from #1875, or at minimum the previous "Node.js X is incompatible with Vite+ CLI" diagnostic.Steps to reproduce
System Info
Used Package Manager
npm
Related
vprshould soft-fallback on incompatible Node versions. This issue is what blocks that fallback from ever being reached on 0.2.1, because the failure happens during ESM instantiation ofterminal-uTv0ZaMr.js, prior to any version-guard logic.Validations
node:utilnamed import).vite-pluspackage).vpr <script>).