nodejs / nodejs/corepack

Expand `corepack use` documentation description

Open
#610 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
3.8k
Forks
279
Avg merge
1h 47m
Merged PRs (30d)
2

Description

Issue

Under README > corepack use the complete description currently says:

corepack use <name[@]>

When run, this command will retrieve the latest release matching the provided descriptor, assign it to the project's package.json file, and automatically perform an install.

package.json location

There is no description of how the command navigates the directory hierarchy to locate a possible existing package.json to modify.

Using the test example of @arcanis in https://github.com/nodejs/corepack/issues/607#issuecomment-2609834263 shows that it operates on the root of a hierarchy:

corepack enable yarn
cd $(mktemp -d)
yarn init -2 -w
mkdir -p packages/foo
echo '{}' > packages/foo/package.json
jq .packageManager package.json
(cd packages/foo && corepack use yarn@4.5.0)
jq .packageManager package.json

In this example case, the result is that:

  • packages/foo/package.json contains {}

  • package.json contains

    {
      "name": "tmp.IcgYOXK7aS",
      "packageManager": "yarn@4.5.0+sha512.837566d24eec14ec0f5f1411adb544e892b3454255e61fdef8fd05f3429480102806bac7446bc9daff3896b01ae4b62d00096c7e989f1596f2af10b927532f39",
      "workspaces": [
        "packages/*"
      ]
    }
    
package.json creation

If no package.json file is found, then one is created. This effect of the command is not described.

Suggestion

For the README > corepack use section:

  • Add text to explain how the location for the package.json file is determined.
  • Add text which describes how a package.json file and / or a packageManager field is created if they don't exist.

Related

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

Update the README's corepack use section, using the linked issue 607 test example and its shell commands as the behavioral reference. Document how the command finds package.json through the directory hierarchy and what it creates when no file or packageManager field exists; done means both behaviors are clearly described.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.