Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[BUG] the package-lock.json generated by npm i errantly contains a ["packages"][""]["name"] property if the npm package is installed in a directory whose name differs from the npm package's name #2812

Closed
sternam opened this issue Mar 3, 2021 · 2 comments
Labels
Bug thing that needs fixing Duplicate duplicate of another, existing issue Release 7.x work is associated with a specific npm 7 release

Comments

@sternam
Copy link

sternam commented Mar 3, 2021

Current Behavior:

If the working directory's name differs from the name of the npm package it contains, then the generated package-lock.json has a ["packages"][""]["name"] property in violation of the npm v7 spec for the package-lock.json file per the docs at https://docs.npmjs.com/cli/v7/configuring-npm/package-lock-json
for example:

{
  "name": "impact-api",
  "version": "2.27.0",
  "lockfileVersion": 2,
  "requires": true,
  "packages": {
    "": {
      "name": "impact-api",
      "version": "2.27.0",
      "license": "UNLICENSED",
      "dependencies": {
...

Expected Behavior:

The generated package-lock.json file should not have a "name" property under ["packages"][""]
for example:

{
  "name": "impact-api",
  "version": "2.27.0",
  "lockfileVersion": 2,
  "requires": true,
  "packages": {
    "": {
      "version": "2.27.0",
      "license": "UNLICENSED",
      "dependencies": {
...

Steps To Reproduce:

  1. clone an npm project/package e.g. from GitHub into a filesystem directory whose name differs from the name of the npm package
  2. remove package-lock.json and the ./node_modules directory if they exist
  3. Run npm i
  4. The generated package-lock.json contains an errant ["packages"][""]["name"] property in violation of the npm v7 spec for the package-lock.json file per the docs at https://docs.npmjs.com/cli/v7/configuring-npm/package-lock-json

Environment:

  • OS: macOS Big Sur Version 11.1
  • Node: 14.16.0
  • npm: 7.6.0
@sternam sternam added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Mar 3, 2021
@shadowspawn
Copy link
Contributor

Related: #2264 #2770

@darcyclarke
Copy link
Contributor

Closing as its a duplicate of #2264

@darcyclarke darcyclarke added Duplicate duplicate of another, existing issue and removed Needs Triage needs review for next steps labels Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Duplicate duplicate of another, existing issue Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

3 participants