NPM task detection reports a parse error for a valid small package.json

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

On every window load, Cursor shows: Npm task detection: failed to parse the file d:\David\Git\aiscr-management\package.json

The file is valid JSON (about 700 bytes). npm ci and npm run succeed in the terminal. The NPM Scripts list stays empty.

The Tasks output only shows that rewritten message. The exception underneath is not a JSON parse failure. It is thrown by $tryOpenDocument before the npm extension reads scripts:

CodeExpectedError: cannot open file:///d%3A/David/Git/aiscr-management/package.json. Detail: Documents above the size limit cannot be synchronized with extensions.
at QCo.$tryOpenDocument (workbench.desktop.main.js)

The sync limit in this build is 50 MB. This package.json is far under it. The npm extension catch replaces every openTextDocument failure with the parse message, so the size-limit detail never reaches the Tasks log.

Steps to Reproduce

  1. Open a local Windows folder whose root package.json is valid and small (single package, not a large monorepo).
  2. Reload the window.
  3. Open Output > Tasks.

The parse error is logged immediately. It happens on every reload, not only during a one-second startup race.

Expected Behavior

NPM scripts from package.json appear in the NPM Scripts view, and Tasks does not report a parse error for a valid file.

Operating System

Windows 10/11

Version Information

Cursor Version: 3.21.18
VSCode Version: 1.128.0
Commit: c4730f7d93d787d9ab120af715999f0345ee5bc0
Build Type: Stable
OS: Windows 10/11

Additional Information

Related closed thread: Bug report 2: NPM task detection fails to parse valid package.json

That thread describes a large pnpm monorepo and a file-open race. This case is a single small package.json and the error is present on every window load. Terminal npm is unaffected.

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey, thanks for the detailed write-up, and your read of the error is correct. This isn’t a parsing issue, and it isn’t a file size issue.

This is a known issue we’re tracking, and I’ve linked your report to it. It affects files that the agent edited in a previous session. After an extension reload, extensions can’t open that file until the editor itself opens it at least once. That’s why you see the misleading “Documents above the size limit”, which the npm extension rewrites as “failed to parse the file”.

Until a fix is in a stable build, here’s a workaround for the current session:

  1. Open package.json in an editor tab click it in Explorer, or use Ctrl+P then type package.json.
  2. In the Explorer sidebar, find the NPM Scripts view and click Refresh.

After that, the scripts should show up, and Output > Tasks should stop showing the error, until the next reload.

Let me know if it worked, and if you remember, has the agent ever edited package.json in this project? I can’t share an ETA for the fix yet, but I’ll update the thread when there’s news.

Thank you. The workaround works with a slight caveat that the package.json file have to be unstaged for this to work.

As for the editing proces, yes, it was Grok 4.7 editing the file on my command.

Glad that helped. And thanks for the clarification about unstaged, that’s a useful detail. I shared it with the team along with your report.

Your confirmation about Grok 4.7 is also spot on. It’s the same files the agent edited in the previous session that trigger this behavior after a reload. So your diagnosis was correct.

I can’t share an ETA for the fix yet, but as soon as I have an update, I’ll reply here in the thread.