Skip to content

bug: vp i pins npm@11 into devEngines on low Node, breaking manual npm with "Cannot find module node:path" #1916

Description

@l246804

Describe the bug

After switching Node to a low version (14.15.0) with vp env use, running vp i fails — but before failing it writes devEngines.packageManager = npm@11.17.0 into the project's package.json (with onFail: "download"), downloads npm 11.17.0, and routes every subsequent npm invocation to it. Because npm 11 requires Node ^20.17.0 || >=22.9.0 and uses require('node:path') (the node: prefix is not supported by Node 14's CommonJS loader), every npm command then crashes — including manual npm i / npm run dev, not just vp i. This breaks the project's toolchain connectivity even though the user never asked for an npm upgrade.

$ npm -v
internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module 'node:path'
Require stack:
- ~/.vite-plus/package_manager/npm/11.17.0/npm/lib/cli.js
- ~/.vite-plus/package_manager/npm/11.17.0/npm/bin/npm-cli.js

The same Cannot find module 'node:path' is thrown by vp i, npm i, and npm run dev — they all hit the vp-managed npm 11.17.0.

Root cause

  1. No node↔npm compatibility check. When vp env use pins Node to 14.15.0 (which ships npm 6.14.8), vp does not honor the bundled npm. Instead, on vp i it pins/writes npm@11.17.0 into devEngines, whose engines field is ^20.17.0 || >=22.9.0 — fundamentally incompatible with Node 14.
  2. Failed vp i still writes side-effect config. vp i fails, yet leaves devEngines.packageManager behind in package.json, permanently routing npm to the incompatible npm 11.

Verified on disk:

  • package.json now contains:
    "devEngines": { "packageManager": { "name": "npm", "version": "11.17.0", "onFail": "download" } }
  • npm 11's cli.js line 10: const cliEntry = require('node:path').resolve(...)
  • npm 11's package.json: "engines": { "node": "^20.17.0 || >=22.9.0" }
  • Node 14.15.0: require('node:path')MODULE_NOT_FOUND

Expected

Scope

To be clear: I'm not asking Vite+ core to support old Node generally. The practical ask is narrower — on unsupported Node versions, provide vp i and vpr passthrough/shims so basic install + script-running still works on legacy enterprise projects that can't be upgraded. That covers the day-to-day project-development flow.

Reproduction

Any project under Node ≤ 16 with vp env use 14.15.0 (or similar low version), then vp i.

Steps to reproduce

vp env use 14.15.0     # node now 14.15.0 (bundles npm 6.14.8)
vp i                   # fails, but writes devEngines.npm@11.17.0 to package.json
npm -v                 # Cannot find module 'node:path'
npm i                  # Cannot find module 'node:path'

Recovery (manual): remove the devEngines block from package.json and avoid vp i on this Node.

System Info

$ vp --version
VITE+ - The Unified Toolchain for the Web
vp v0.2.1

Environment:
  Package manager  npm v11.17.0
  Node.js          v14.15.0 (.node-version)

$ vp env current
VITE+ - The Unified Toolchain for the Web

Environment:
  Version       14.15.0
  Source        .node-version
  Project Root  <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

Package Manager:
  Name          npm
  Version       11.17.0
  Source        devEngines.packageManager
  Source Path   <project>/package.json
  Bin Path      ~/.vite-plus/package_manager/npm/11.17.0/npm/bin/npm

Note: vp --version / vp env current work fine (they don't spawn the npm binary); only commands that actually exec npm — vp i, npm, npm run <script> — crash.

Used Package Manager

npm

Logs

$ vp i
internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module 'node:path'
Require stack:
- ~/.vite-plus/package_manager/npm/11.17.0/npm/lib/cli.js
- ~/.vite-plus/package_manager/npm/11.17.0/npm/bin/npm-cli.js

Related

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions