cli icon indicating copy to clipboard operation
cli copied to clipboard

[BUG] `npm stars` command not showing starred packages

Open MaxBlack-dev opened this issue 1 month ago • 1 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

This issue exists in the latest npm version

  • [x] I am using the latest npm

Current Behavior

npm stars always returns "user has not starred any packages" even after successfully starring packages with npm star <package>.

Expected Behavior

npm stars should list packages that the user has starred.

Steps To Reproduce

npm whoami  # returns: max-black
npm star lodash  # returns: ★ lodash  
npm stars  # returns: npm warn stars user has not starred any packages 


### Environment

- npm CLI: 11.6.2
- Node.js: v22.11.0
- OS: macOS, Windows
- Registry: https://registry.npmjs.org/

**Root Cause:**
The issue is not in the CLI code but in the registry's CouchDB view infrastructure:

1. ✅ Package starring works (confirmed: `max-black: true` appears in lodash's `users` field)
2. ❌ CouchDB view `/-/_view/starredByUser` returns empty results despite successful stars
3. 🔍 This indicates a view synchronization issue in the registry infrastructure

**Evidence:**
```bash
# Starring works - user appears in package document
curl "https://registry.npmjs.org/lodash" | jq '.users["max-black"]'
# Returns: true

# View is broken - doesn't reflect the starred packages  
curl "https://registry.npmjs.org/-/_view/starredByUser?key=\"max-black\"" 
# Returns: {"rows": []}

Impact:

  • The npm stars command is completely non-functional for all users
  • This is a registry infrastructure issue, not a CLI bug
  • Workaround: Check starred packages on npmjs.com website

Files:

  • lib/commands/stars.js - CLI implementation (correct)
  • Registry CouchDB views - broken synchronization

This appears to be a significant registry infrastructure issue that requires attention from the npm registry team.

Important for issue handlers: If you cannot reproduce this issue, please don't close immediately. Instead, please help us understand why the API returns different results for different users/environments before closing. We have consistent reproduction across multiple environments and users. Especially why this returns empty array - curl "https://registry.npmjs.org/-/_view/starredByUser?key="max-black""

GITHUB_ISSUE.md

MaxBlack-dev avatar Oct 30 '25 17:10 MaxBlack-dev

Update: Root Cause Identified

I've been investigating this issue further and found the root cause:

The API Endpoint Source

The /-/_view/starredByUser endpoint that the npm stars command uses is defined in the npm-registry-couchapp repository. Specifically, the view definition is in registry/views.js:

views.starredByUser = { map : function (doc) {
  if (!doc || !doc.users) return
  Object.keys(doc.users).forEach(function (m) {
    if (!doc.users[m]) return
    emit(m, doc._id)
  })
}}

The Problem

However, this repository has been archived since January 2021 and the README explicitly states:

npm-registry-couchapp is still a core part of our functionality, but all new registry features are now added to the micro-services that now make up npm. For this reason, we will not be accepting any pull requests, or making any changes to this codebase going forward.

This means:

  • ❌ The repository is read-only and doesn't accept PRs
  • ❌ The view synchronization issue cannot be fixed via GitHub
  • ❌ The microservices that replaced this architecture are not open source

Question for npm Team

Is there an open-source repository for the microservices that have replaced the CouchDB views? If the registry infrastructure has moved to microservices, is there any public repository where community members can:

  • Investigate view synchronization issues
  • Contribute fixes for broken endpoints
  • Report infrastructure bugs

Without access to the actual service code, this issue can only be resolved by npm's internal team through support tickets.

Current Status

I've reported this to npm support (ticket #12EYV9-4M35D) and they're investigating the view synchronization issue. This appears to be a registry infrastructure problem that requires backend intervention to rebuild or fix the starredByUser view.

MaxBlack-dev avatar Nov 15 '25 01:11 MaxBlack-dev