Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG] Installing an aliased package with an empty name will install the 'undefined' package #7590

Closed
2 tasks done
okx-code opened this issue Jun 12, 2024 · 2 comments · Fixed by npm/npm-package-arg#184
Closed
2 tasks done
Assignees
Labels
Bug thing that needs fixing Priority 2 secondary priority issue

Comments

@okx-code
Copy link

okx-code commented Jun 12, 2024

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

Installing an aliased package with no name will actually install the package 'undefined'

Expected Behavior

Installing an aliased package with no name should fail.

Steps To Reproduce

  1. Create an project with npm init
  2. Run npm install a@npm:
npm warn deprecated undefined@0.1.0: this package has been deprecated

added 1 package, and audited 2 packages in 763ms

found 0 vulnerabilities
  1. Look at package-lock.json, and see that it evaluated to 'undefined':
{
  "name": "bug",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "bug",
      "version": "1.0.0",
      "license": "ISC",
      "dependencies": {
        "a": "npm:undefined@^0.1.0"
      }
    },
    "node_modules/a": {
      "name": "undefined",
      "version": "0.1.0",
      "resolved": "https://registry.npmjs.org/undefined/-/undefined-0.1.0.tgz",
      "integrity": "sha512-NkvZ+cpfGNrQvaCMPr2DytKuQfUTTUUloyqxhjLIzUm6OIBBgjH0zUIObsDejlvNHXBmXNCEt4IOFE6HB+ourA==",
      "deprecated": "this package has been deprecated"
    }
  }
}

I think the issue is in the npa function of npm-package-arg, I will submit a PR to fix this, but wanted to file an issue first.

Environment

  • npm: 10.8.1
@okx-code okx-code added Bug thing that needs fixing Needs Triage needs review for next steps labels Jun 12, 2024
@ljharb
Copy link
Contributor

ljharb commented Jun 12, 2024

Presumably it should fail to install, since the name field is required?

@okx-code
Copy link
Author

Yes, it should fail.

@milaninfy milaninfy added Priority 2 secondary priority issue and removed Needs Triage needs review for next steps labels Jun 12, 2024
@milaninfy milaninfy self-assigned this Jul 12, 2024
wraithgar pushed a commit to npm/npm-package-arg that referenced this issue Jul 22, 2024
throws error when alias spec is without name. e.g. ( foo@npm: )
Fixes: npm/cli#7590
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bug thing that needs fixing Priority 2 secondary priority issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants