Skip to content

The entire package.json is used as the "node version" when using node-versions-file #864

Description

@NullVoxPopuli

Description:

There is a message about not finding the node version in the manifest, so it says it'll fallback to downloading node, but it uses the entire package.json as the "node version", rather than an actual semver-style version

Run actions/setup-node@v3
  with:
    node-version-file: package.json
    always-auth: false
    check-latest: false
    token: ***
Resolved package.json as {}
Attempting to download {}...
Not found in manifest. Falling back to download directly from Node
Error: Unable to find Node version '{}' for platform linux and architecture x64.

Example: https://github.com/NullVoxPopuli/actions-testing/actions/runs/6410471015/job/17403838984

Action version:
v3

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:
defaults

Repro steps:

a job that does:

  aaa:
    name: 'actions/setup-node (with node-version-file: empty package.json)'
    runs-on: ubuntu-latest
    steps: 
      - uses: actions/checkout@v4
      # clear the package.json
      - run: 'echo "{}" > package.json'
      - uses: actions/setup-node@v3
        with:
          node-version-file: package.json
      - run: node --version

https://github.com/NullVoxPopuli/actions-testing/blob/main/.github/workflows/testing.yml#L29-L39

Another example, where I put a name entry in the package.json

  aaa:
    name: 'actions/setup-node (with node-version-file: empty package.json)'
    runs-on: ubuntu-latest
    steps: 
      - uses: actions/checkout@v4
      # clear the package.json
      - run: 'echo "{ \"name\": \"test\" }" > package.json'
      - uses: actions/setup-node@v3
        with:
          node-version-file: package.json
      - run: node --version

Results in:

Run actions/setup-node@v3
  with:
    node-version-file: package.json
    always-auth: false
    check-latest: false
    token: ***
Resolved package.json as { "name": "test" }
Attempting to download { "name": "test" }...
Not found in manifest. Falling back to download directly from Node
Error: Unable to find Node version '{ "name": "test" }' for platform linux and architecture x64.

https://github.com/NullVoxPopuli/actions-testing/actions/runs/6410629979/job/17404330263#step:4:11

Expected behavior:
ignore node-version-file, since it does not contain a node version, and the entire file itself (which is json) is not a valid version)

Actual behavior:
the entire json file is being used as the version.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions