Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Expand `corepack use` documentation description

未关闭
#610 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1-3 小时
新手友好度
45/100
Issue 类型
文档
描述清晰度
描述清楚
活跃度
停滞
领域
documentation

调研方向

更新 README 的 corepack use 部分,以链接的 issue 607 测试示例及其 shell 命令作为行为参考。记录该命令如何通过目录层级查找 package.json,以及在不存在文件或 packageManager 字段时会创建什么;当这两种行为都得到清晰描述时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

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

主要语言
TypeScript
星标
3.8k
派生
279
平均合并
1 小时 47 分钟
30 天内合并 PR
2

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

nodejs/corepack 的其他 Issue

查看 nodejs/corepack 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。