antfu / antfu/node-modules-inspector

Handle private package npm metadata fetching failures better

Open
#65 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Clear and concise description of the problem

When fetching npm meta for private packages, it prints warnings like:

Failed to get npm meta for: [ 'undefined@undefined' ]

I know the private package's meta can't be fetched from the https://npm.antfu.dev/ endpoint, but it seems the error wasn't handled correctly.

Suggested solution

https://github.com/antfu/node-modules-inspector/blob/2573b65652b20fff01f39e685432f8861c002c89/packages/node-modules-inspector/src/shared/version-info.ts#L24-L31

The result might be:

{
  url: '/...',
  statusCode: 500,
  statusMessage: '',
  message: '[GET] "https://registry.npmjs.org/some-private-package": 404 Not Found'
}

We could either handle this to improve the warning logs (insteas of undefined@undefined)
or fetch npm meta using current private registry URL (e.g., https://private-registry.com/some-private-package)

Alternative

No response

Additional context

I'm willing to submit a PR for this. 🙌🏻

Validations

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 in packages/node-modules-inspector/src/shared/version-info.ts around lines 24–31 and reproduce the warning while fetching metadata for a private package. Determine whether the implementation should use the current private registry or improve the failed-fetch warning; done means the selected behavior no longer reports the package as undefined@undefined.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.