antfu / antfu/node-modules-inspector

Invalid string length

Open
#102 3 comments 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.9k
Forks
90
Avg merge
2d 3h
Merged PRs (30d)
9

Description

Describe the bug

Just tried to run this first time using Windows + Powershell and got this error:

❯ pnpx node-modules-inspector
Packages: +68
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 68, reused 0, downloaded 68, added 68, done
⬢ Starting Node Modules Inspector at http://localhost:9999 

⬢ Reading node_modules...
✔ Websocket client connected
Failed to parse JSON output from pnpm ls
{ error: { code: 'pnpm', message: 'Invalid string length' } }
file:///C:/Users/pegak/AppData/Local/pnpm-cache/dlx/b81ca73f0f9090324044485603825baafdaf6c1b1593cfb9acb9a8667c8a737f/196836a97ac-5cf4/node_modules/.pnpm/node-modules-tools@0.6.7/node_modules/node-modules-tools/dist/chunks/json-parse-stream.mjs:855
          throw new JsonParseStreamError(`Failed to parse JSON output from ${sourceName}`, assembler.current);
          ^

JsonParseStreamError: Failed to parse JSON output from pnpm ls
    at Parser.<anonymous> (file:///C:/Users/pegak/AppData/Local/pnpm-cache/dlx/b81ca73f0f9090324044485603825baafdaf6c1b1593cfb9acb9a8667c8a737f/196836a97ac-5cf4/node_modules/.pnpm/node-modules-tools@0.6.7/node_modules/node-modules-tools/dist/chunks/json-parse-stream.mjs:855:17)
    at Parser.emit (node:events:518:28)
    at addChunk (node:internal/streams/readable:561:12)
    at readableAddChunkPushObjectMode (node:internal/streams/readable:538:3)
    at Readable.push (node:internal/streams/readable:393:5)
    at Parser._processBuffer (file:///C:/Users/pegak/AppData/Local/pnpm-cache/dlx/b81ca73f0f9090324044485603825baafdaf6c1b1593cfb9acb9a8667c8a737f/196836a97ac-5cf4/node_modules/.pnpm/node-modules-tools@0.6.7/node_modules/node-modules-tools/dist/chunks/json-parse-stream.mjs:383:19)
    at Parser._transformBuffer (file:///C:/Users/pegak/AppData/Local/pnpm-cache/dlx/b81ca73f0f9090324044485603825baafdaf6c1b1593cfb9acb9a8667c8a737f/196836a97ac-5cf4/node_modules/.pnpm/node-modules-tools@0.6.7/node_modules/node-modules-tools/dist/chunks/json-parse-stream.mjs:37:11)
    at Parser._transform (file:///C:/Users/pegak/AppData/Local/pnpm-cache/dlx/b81ca73f0f9090324044485603825baafdaf6c1b1593cfb9acb9a8667c8a737f/196836a97ac-5cf4/node_modules/.pnpm/node-modules-tools@0.6.7/node_modules/node-modules-tools/dist/chunks/json-parse-stream.mjs:32:11)
    at Transform._write (node:internal/streams/transform:171:8)
    at writeOrBuffer (node:internal/streams/writable:572:12) {
  data: { error: { code: 'pnpm', message: 'Invalid string length' } }
}

Node.js v22.14.0
Reproduction
  1. Use Windows + Powershell
  2. Run pnpx node-modules-inspector in any repository
  3. Observe crash.
System Info
System:
    OS: Windows 11 10.0.26120
    CPU: (16) x64 AMD Ryzen 7 6800HS with Radeon Graphics         
    Memory: 14.09 GB / 31.26 GB
  Binaries:
    Node: 22.14.0 - ~\.proto\shims\node.EXE
    npm: 10.9.1 - ~\.proto\shims\npm.EXE
    pnpm: 10.8.1 - ~\.proto\shims\pnpm.EXE
    bun: 1.2.10 - ~\.proto\shims\bun.EXE
  Browsers:
    Edge: Chromium (133.0.3065.10)
    Internet Explorer: 11.0.26100.1
Used Package Manager

pnpm

Validations
  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
Contributions
  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing pnpx node-modules-inspector under Windows PowerShell, then trace the pnpm ls JSON parsing path from the json-parse-stream.mjs stack-trace entry. Done means the inspector completes startup and reads node_modules without the “Invalid string length” crash in this environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, powershell, typescript
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.