Skip to content

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

Closed

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

  1. added a commit that references this issue on Oct 4, 2023
  2. NullVoxPopuli commented on Oct 4, 2023

    @NullVoxPopuli
    ContributorAuthor

    PR to fix here: #865

  3. marko-zivic-93 commented on Oct 6, 2023

    @marko-zivic-93
    Contributor

    Hello @NullVoxPopuli,
    Thank you for creating this issue and contributing with a PR, we will take a look and come back to you as soon as we have some news 😃

  4. Techn1x commented on Oct 10, 2023

    @Techn1x

    I think the above poster ikjot161290 is a bot, not sure how to report comments on github..

  5. added a commit that references this issue on Oct 25, 2023
  6. added a commit that references this issue on Dec 11, 2023
  7. v-aparnajyothi-y commented on Dec 19, 2023

    @v-aparnajyothi-y
    Contributor

    Hello @NullVoxPopuli, Released the PR yesterday.

    For now I am going to close the issue. If you have any concerns feel free to ping us.

  8. NullVoxPopuli commented on Dec 19, 2023

    @NullVoxPopuli
    ContributorAuthor
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