Skip to content

vp staged --debug crashes by reading vite-plus/dist/package.json instead of lint-staged's package.json #1922

Description

@rokuosan

Describe the bug

vp staged succeeds, but adding --debug causes Vite+ to crash while trying to read vite-plus/dist/package.json.

Expected:

  • vp staged --debug should succeed and print the bundled lint-staged version correctly

Actual:

  • vp staged --debug throws ENOENT for vite-plus/dist/package.json

Example with --debug:

$ vp staged --debug
node:internal/fs/promises:640
  return new FileHandle(await PromisePrototypeThen(
                        ^

Error: ENOENT: no such file or directory, open '/Users/rokuosan/.local/share/mise/installs/viteplus/0.2.1/lib/node_modules/vite-plus/dist/package.json'
    at async open (node:internal/fs/promises:640:25)
    at async Object.readFile (node:internal/fs/promises:1290:14)
    at async getVersion (file:///Users/rokuosan/.local/share/mise/installs/viteplus/0.2.1/lib/node_modules/vite-plus/dist/staged/bin.js:6490:20)
    at async lintStaged (file:///Users/rokuosan/.local/share/mise/installs/viteplus/0.2.1/lib/node_modules/vite-plus/dist/staged/bin.js:6542:59)
    at async file:///Users/rokuosan/.local/share/mise/installs/viteplus/0.2.1/lib/node_modules/vite-plus/dist/staged/bin.js:6747:18 {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/Users/rokuosan/.local/share/mise/installs/viteplus/0.2.1/lib/node_modules/vite-plus/dist/package.json'
}

Node.js v24.17.0

Example without --debug:

$ vp staged
✔ Backed up original state in git stash (825fd1e)
✔ Hiding unstaged changes to partially staged files...
✔ Running tasks for staged files...
✔ Applying modifications from tasks...
✔ Restoring unstaged changes...
✔ Cleaning up temporary files...

This appears to be a Vite+ packaging/bundling issue rather than a lint-staged issue. The bundled staged entry contains lint-staged@16.4.0, but getVersion() resolves ../package.json relative to the bundled file, so it ends up reading vite-plus/dist/package.json.

Local-only workaround

As a local workaround, adding dist/package.json avoids the crash:

diff --git a/dist/package.json b/dist/package.json
new file mode 100644
index 0000000..653bf6d
--- /dev/null
+++ b/dist/package.json
@@ -0,0 +1,3 @@
+{
+  "version": "16.4.0"
+}

Reproduction

https://github.com/rokuosan/repro-vp-staged-debug

Steps to reproduce

  1. Create a project with vite-plus@0.2.1
  2. Configure staged in vite.config.ts
  3. Stage at least one file
  4. Run:
$ vp staged --debug

System Info

vp env current is mentioned in the issue template, but on vite-plus@0.2.1 it is not available in this environment:

error: Command 'env' not found

vp --version output:

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

vp v0.2.1

Local vite-plus:
  vite-plus  v0.2.1

Tools:
  vite             v8.0.16
  rolldown         v1.1.1
  vitest           v4.1.9
  oxfmt            v0.55.0
  oxlint           v1.70.0
  oxlint-tsgolint  v0.23.0
  tsdown           v0.22.3


`sw_vers` output:


$ sw_vers
ProductName:            macOS
ProductVersion:         26.3
BuildVersion:           25D125

Used Package Manager

pnpm

Logs

Validations

Metadata

Metadata

Labels

bugSomething isn't working

Type

Priority

None yet

Effort

None yet

Target date

None yet

Start date

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions