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

nodeenv falls back to /usr/bin/nodejs instead of the node installed by actions/setup-node

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

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
github-actions, node.js, typescript
领域
ci-cd, devops

调研方向

先从 actions/setup-node@v4 workflow 和 nodeenv.py 中 931-938 行附近的查找逻辑开始,然后复现链接的 GitHub Actions job 中失败的 pre-commit 运行。跟踪 Ubuntu 托管 runner 上选择了哪个可执行文件;当选择了配置的 Node 16 安装并且 Prettier hook 成功时,该 issue 即完成。

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

描述

feature request

Description:
In a runs-on: ubuntu-latest GitHub hosted runner, I found that even after doing:

      - name: Set up Node
        uses: actions/setup-node@v4
        with:
          node-version: 16

that pre-commit run -a was failing to run a pre-commit hook configured as:

  - repo: https://github.com/pre-commit/mirrors-prettier
    rev: v3.1.0
    hooks:
      - id: prettier
        args: [--no-editorconfig]
        exclude: "^asv\\.conf\\.json$"
        exclude_types: [html]

with an error saying:

prettier requires at least version 14 of Node, please upgrade

Which was surprising, seeing as how we had just installed node version 16.

It turns out that pre-commit runs nodeenv, and nodeenv looks first for a binary named nodejs, and then falls back to looking for one named node:

https://github.com/ekalinin/nodeenv/blob/eaa9de97e561ab4f99458c94633e92547e72d5f1/nodeenv.py#L931-L938

And it seems like actions/setup-node is only installing one named node, and not one named nodejs, so nodeenv found /usr/bin/nodejs first and preferred that over /opt/hostedtoolcache/node/16.20.2/x64/bin/node.

Should the hostedtoolcache contain a nodejs as well? Or perhaps nodeenv should prefer node over nodejs?

Action version:
actions/setup-node@v4

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:

Repro steps:
See https://github.com/bloomberg/memray/actions/runs/6984525297/job/19007471664 for a failed run where /usr/bin/nodejs was chosen instead of /opt/hostedtoolcache/node/16.20.2/x64/bin/node

主要语言
TypeScript
星标
5k
派生
1.7k
平均合并
2 天 11 小时
30 天内合并 PR
3

贡献指南

这个仓库没有索引到贡献指南

从这里开始

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

actions/setup-node 的其他 Issue

查看 actions/setup-node 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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