npm / npm/cli

[BUG] ENOVERSIONS for undefined when using github dependency

Open
#6,577 3 comments 0 reactions 0 assignees View on GitHub

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

Package name reads 'undefined' in ENOVERSIONS error when dependency is a git(hub) package.

$ npm i -D alt-jero/my-private-package#semver:~0.0.2
npm ERR! code ENOVERSIONS
npm ERR! No versions available for undefined

npm ERR! A complete log of this run can be found in: /Users/jero/.npm/_logs/2023-06-20T23_27_09_712Z-debug-0.log

Probably the 'undefined' is referring to the name field of the package.json, which hasn't been fetched because the requested version tag was not found.

Expected Behavior

'Method' references "Steps to Reproduce".

For method 1: Use the URL specified in the command (without the semver hash)

npm ERR! code ENOVERSIONS
npm ERR! No versions available for <your github username>/the-dependency

For method 2: Use the name specified in package.json of the host

npm ERR! code ENOVERSIONS
npm ERR! No versions available for the-dependency

Also, a short explanatory text might go a long way:

npm INFO: Versions must be defined as git tags
npm INFO: If you can push to the repository, ensure you have also pushed the tags
npm INFO: If you cannot alter the repository, omit the semver specifier
Steps To Reproduce

Setup:

  1. The Dependency – Create a github repo containing a package.json with version 1.0.0 but no git version tags.
  2. The Host – Create a local directory and npm init it.
  3. Proceed

Method 1: CLI

  1. run npm i <your github username>/the-dependency#semver:~1.0.0
  2. Wait...
  3. Observe the error

Method 2: package.json

  1. Add "your-test-package": "<your github username>/the-dependency#semver:~1.0.0" to the package.json of the host
  2. run npm i
  3. Wait, and observe the error
Environment
  • npm: 9.7.1
  • Node.js: v18.8.0
  • OS Name: macOS Big Sur (11.7.7)
  • System Model Name: MacBook Air (mid-2013)
  • npm config:
; "user" config from /Users/jero/.npmrc

//registry.npmjs.org/:_authToken = (protected)

; node bin location = /usr/local/bin/node
; node version = v18.8.0
; npm local prefix = /Users/jero/dev
; npm version = 9.7.1
; cwd = /Users/jero/dev
; HOME = /Users/jero
; Run `npm config ls -l` to show all defaults.

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 the CLI command and the package.json dependency case described in Steps To Reproduce, then trace npm CLI's GitHub dependency version resolution and ENOVERSIONS error formatting. Done means the error identifies the dependency instead of reporting undefined, with the requested guidance about Git tags addressed if in scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli, 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.