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

packages keys do not appear to be true paths #645

Open
craxal opened this issue Jun 2, 2023 · 4 comments
Open

packages keys do not appear to be true paths #645

craxal opened this issue Jun 2, 2023 · 4 comments
Labels
content Issues or PRs related to the content of the docs

Comments

@craxal
Copy link

craxal commented Jun 2, 2023

Documentation for the keys of the packages property in package-lock.json files describes them as "relative paths from the root project folder". This does not appear to be entirely true.

Consider the following package.json:

package.json:

{
  "name": "my-project",
  "dependencies": {
    "@scope/package-a": "^1.0.0",
  }
}

Assume also that "@scope/package-a" has a dependency on a package called "@scope.package-b". When npm installs dependencies, the project directory structure looks like this:

my-project
├─node_modules
│ └─@scope
│   ├─package-a
│   └─package-b
├─package.json
└─package-lock.json

However, package-lock.json has the following entry under packages:

"node_modules/@scope/package-a/node_modules/@scope/package-b": {
  "version": "1.0.0",
  ...
},

Notice the path does not actually exist in the directory.

Documentation should be clear about whether this is expected or whether the relative paths, as described, are true paths.

@ljharb
Copy link
Contributor

ljharb commented Jun 2, 2023

They're paths into the ideal tree, I believe, not the actual tree on disk.

@craxal
Copy link
Author

craxal commented Jun 2, 2023

@ljhard I figured. But that's not clear in the documentation. A project I'm on requires information from the package lock file, and I would have been saved a lot of frustration if the documentation had been clearer about that on this point.

@ljharb
Copy link
Contributor

ljharb commented Jun 2, 2023

I'd suggest using arborist, rather than directly accessing a lockfile or node_modules.

@craxal
Copy link
Author

craxal commented Jun 3, 2023

@ljhard Thank you for the suggestion. I can consider that. Regardless, this issue is about having clearer npm documentation.

@lukekarrys lukekarrys added the content Issues or PRs related to the content of the docs label Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Issues or PRs related to the content of the docs
Projects
None yet
Development

No branches or pull requests

5 participants
@ljharb @lukekarrys @craxal and others