[BUG] Invalid json output when using `npm search <search term> --json`
Open
Nobody has claimed this yet.
Bug
Priority 2
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
Is there an existing issue for this?
- I have searched the existing issues
This issue exists in the latest npm version
- I am using the latest npm
Current Behavior
When running npm search <search term> --json, the output can include invalid json that cannot be parsed using JSON.parse
Expected Behavior
When running npm search <search term> --json, the output should include valid json that can be parsed using JSON.parse
Steps To Reproduce
- Run
npm search @khanacademy/wonder-blocks --json --searchlimit=1000 - Notice that the output includes invalid json:
> npm search @khanacademy/wonder-blocks --json --searchlimit=1000
[
...,
{
"name":"@automattic/newspack-blocks",
// ... other fields
"sanitized_name":***@automattic/newspack-blocks" // missing quotation between the : and ***
},
...,
]
Environment
- npm: 11.11.0
- Node.js: 24.13.1
- OS Name: Tahoe 26.3.1
- System Model Name: Macbook Pro
- npm config:
; "user" config from /Users/beaesguerra/.npmrc
@khan:registry = "https://npm.pkg.github.com"
//npm.pkg.github.com/:_authToken = (protected)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with npm search @khanacademy/wonder-blocks --json --searchlimit=1000 and inspect the npm search command's JSON output path. Compare the emitted output with what JSON.parse accepts, then verify that the command consistently produces valid JSON for the reported search.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100