GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Enable caching by default if `packageManager` field is defined in package.json · Issue #686 · actions/setup-node

Enable caching by default if packageManager field is defined in package.json #686

New issue
Copy link
New issue
Copy link
Closed
Closed
Enable caching by default if packageManager field is defined in package.json#686
Copy link
Assignees
v-priya-kinthali
Labels
feature requestNew feature or request to improve the current logic

Description

@trivikr
trivikr
opened on Jan 31, 2023
Issue body actions

Description:
The action allows caching global packages data as per documentation in https://github.com/actions/setup-node#caching-global-packages-data

It's an amazing feature and reduces action execution time, but it has to be enabled in configuration.
Caching is not enabled in default setup. Users may not discover caching feature by default, and miss on the faster executions times enabled by caching.

The feature request is to enable caching by default if packageManager field is defined.
This can be enabled in a major version bump, say v4, to not affect existing users.

Justification:
Just want all users to get benefit of faster executions times allowed by caching without explicitly opting in, if they have set up packageManager field in their package.json

They can always explicitly opt-out by setting cache to empty string.

Are you willing to submit a PR?
Yes

Reacted by sid, George Fu, Michael Young, kpietraszko, Alexander Kachkaev, Emilio Martinez, Nato Boram, Manu Chandrasekhar, Alex Kozack, Ari Becker and 16 more
Reacted by Jan Kowalleck
Reacted by Lex

Activity

  1. trivikr
    added
    feature requestNew feature or request to improve the current logic
    needs triage
    on Jan 31, 2023
  2. trivikr commented on Jan 31, 2023

    @trivikr
    trivikr
    on Jan 31, 2023
    ContributorAuthor
    More actions

    I think the implementation can be as simple as

    -    if (cache && isCacheFeatureAvailable()) {
    +    const packageManagerFromManifest = getNameFromPackageManagerField();
    +    if ((cache !== "" || packageManagerFromManifest) && isCacheFeatureAvailable()) {
           const cacheDependencyPath = core.getInput('cache-dependency-path');
    -      await restoreCache(cache, cacheDependencyPath);
    +      const packageManager = cache !== "" ? cache : packageManagerFromManifest;
    +      await restoreCache(packageManager, cacheDependencyPath);
         }

    where getNameFromPackageManagerField returns the package manager name from packageManager field. That is:

    • yarn if the value is [email protected]
    • pnpm is the value is [email protected]
    • undefined otherwise

    Other package managers can be added, once they are supported

  3. MaksimZhukov commented on Feb 1, 2023

    @MaksimZhukov
    MaksimZhukov
    on Feb 1, 2023
    Contributor
    More actions

    Hello @trivikr ! Thank you for the suggested idea!
    We will consider adding this feature and will let you know as soon as we have any decision.

    Reacted by Nato Boram, Trivikram Kamat and roman zanettin
  4. MaksimZhukov
    removed
    needs triage
    on Feb 1, 2023
  5. Airkro commented on Sep 16, 2023

    @Airkro
    Airkro
    on Sep 16, 2023
    More actions

    This is what I doing before this feature landed:

    jobs:
      steps:
        - name: Checkout
          uses: actions/checkout@v3
    
        - name: Detect package manager
          shell: bash
          run: node -p "'PACKAGE_MANAGER='+require('./package.json').packageManager?.split?.('@')?.[0]" >> "$GITHUB_ENV"
    
        - name: Install pnpm
          run: corepack enable pnpm
          if: ${{ env.PACKAGE_MANAGER == 'pnpm' }}
          # install pnpm before setup-node
    
        - name: Setup node
          uses: actions/setup-node@v3
          with:
            node-version: lts
            cache: ${{ env.PACKAGE_MANAGER }}
  6. trivikr commented on Mar 25, 2025

    @trivikr
    trivikr
    on Mar 25, 2025
    ContributorAuthor
    More actions

    Revisiting this, as devEngines has now appeared as a standard in Node.js ecosystem.
    It'll be better to track devEngines.packageManager instead of (or in addition to) packageManager field.

    It's implemented by [email protected] as well as [email protected].

    Reacted by v-aparnajyothi-y and Guillaume Humbert
  7. v-priya-kinthali
    self-assigned this
    on Jul 30, 2025
  8. v-HarithaVattikuti commented on Aug 22, 2025

    @v-HarithaVattikuti
    v-HarithaVattikuti
    on Aug 22, 2025
    Contributor
    More actions

    Hello Everyone,
    We’ve raised PR #1348 to address the above request. Please validate it against the requirement, and confirm to proceed further.
    Feel free to reach out if you have any questions or need further clarification.

  9. v-priya-kinthali commented on Aug 28, 2025

    @v-priya-kinthali
    v-priya-kinthali
    on Aug 28, 2025
    Contributor
    More actions

    Hello everyone👋,
    The requested feature has now been implemented and the related PR#1348 has been merged. This update supports enabling caching when a valid package manager field is detected. To disable this automatic caching, set package-manager-cache to false.
    To utilise this feature, you can use the actions/setup-node@main branch in your workflows for now, and the changes will be reflected in the upcoming releases.
    We’ll be closing this issue. Please feel free to reach out if you have any further concerns or need additional assistance.
    Thanks again for your suggestion and feedback!

    Reacted by TOMIKAWA Sotaro, Guillaume Humbert, Sʜɪᴍᴜʀᴀ Yū and Jonas Thelemann
    Reacted by Jonas Thelemann and Trivikram Kamat
  10. v-priya-kinthali
    closed this as completedon Aug 28, 2025
  11. kleinfreund commented on Sep 4, 2025

    @kleinfreund
    kleinfreund
    on Sep 4, 2025
    More actions

    Revisiting this, as devEngines has now appeared as a standard in Node.js ecosystem.
    It'll be better to track devEngines.packageManager instead of (or in addition to) packageManager field.

    Was there a particular reason not to look at devEngines in https://github.com/actions/setup-node/pull/1348/files#diff-4fab5baaca5c14d2de62d8d2fceef376ddddcc8e9509d86cfa5643f51b89ce3dR139 (e.g. via const pm = packageJson.devEngines?.packageManager ?? packageJson.packageManager;) first?

    Reacted by Daniel Bayley and Derek Lindahl
  12. v-priyagupta108 commented on Sep 22, 2025

    @v-priyagupta108
    v-priyagupta108
    on Sep 22, 2025
    Contributor
    More actions

    Hello 👋,

    We’re planning to update this feature so that caching is automatically enabled for npm, while caching will be disabled by default for other package managers (pnpm and yarn). This adjustment is being made based on recent issues with pnpm and yarn integration. For more background, please see issue #1357.
    Our goal with this change is to ensure reliability and prevent failures like those reported for pnpm and yarn. If you have any concerns or suggestions, please share your feedback!

    Thank you for your understanding and support.

    Reacted by Alexander Kachkaev
  13. MikeMcC399 commented on Sep 26, 2025

    @MikeMcC399
    MikeMcC399
    on Sep 26, 2025
    Contributor
    More actions

    @priyagupta108

    Enabling Yarn caching through actions/setup-node@v5 by default will break CI in nodejs/corepack if updated from v4 to v5. This GitHub Actions CI sets the environment variable YARN_ENABLE_GLOBAL_CACHE: false.

    In a test branch https://github.com/MikeMcC399/corepack/tree/test/setup-node-v5 I simply updated from actions/setup-node@v4 to actions/setup-node@v5 and the workflow failed with:

    Run actions/setup-node@v5
    Attempt to resolve LTS alias from manifest...
    (node:2071) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
    (Use `node --trace-deprecation ...` to show where the warning was created)
    Found in cache @ /opt/hostedtoolcache/node/22.19.0/x64
    Environment details
    /usr/local/bin/yarn --version
    1.22.22
    /usr/local/bin/yarn cache dir
    error This project's package.json defines "packageManager": "[email protected]". However the current global version of Yarn is 1.22.22.
    
    Presence of the "packageManager" field indicates that the project is meant to be used with Corepack, a tool included by default with all official Node.js distributions starting from 16.9 and 14.19.
    Corepack must currently be enabled by running corepack enable in your terminal. For more information, check out https://yarnpkg.com/corepack.
    Error: error This project's package.json defines "packageManager": "[email protected]". However the current global version of Yarn is 1.22.22.
    
    Presence of the "packageManager" field indicates that the project is meant to be used with Corepack, a tool included by default with all official Node.js distributions starting from 16.9 and 14.19.
    Corepack must currently be enabled by running corepack enable in your terminal. For more information, check out https://yarnpkg.com/corepack.
    

    After disabling cache in a different branch https://github.com/MikeMcC399/corepack/tree/test/setup-node-v5-no-cache with

          - uses: actions/setup-node@v5
            with:
              node-version: lts/*
              package-manager-cache: false

    the workflow succeeded.

    • Since there is already a PR Limit automatic caching to npm, update workflows and documentation #1374 to disable default caching for Yarn, I won't submit a separate issue for the above.
  14. v-aparnajyothi-y commented on Sep 26, 2025

    @v-aparnajyothi-y
    v-aparnajyothi-y
    on Sep 26, 2025
    Contributor
    More actions

    Hello Everyone, As part of PR #1374, we introduce detection support for devEngines.packageManager, enabling automatic caching for npm dependencies. This update will be included in the upcoming patch release of v5. We hope this enhancement helps streamline workflows and improve consistency across your projects.

    Your feedback and suggestions are appreciated. Please take a look and share your thoughts.

  15. sschuberth
    added 4 commits that reference this issue on Feb 11, 2026

    ci(github): Stop installing PNPM manually but leave it to CorePack

    a7d725c

    ci(github): Stop installing PNPM manually but leave it to CorePack

    c853efb

    ci(github): Stop installing PNPM manually but leave it to Corepack

    4897439

    ci(github): Stop installing PNPM manually but leave it to Corepack

    c795791
  16. github-merge-queue
    added a commit that references this issue on Feb 11, 2026

    ci(github): Stop installing PNPM manually but leave it to Corepack

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

Metadata

Metadata

Assignees

  • @v-priya-kinthali
    v-priya-kinthali

Labels

feature requestNew feature or request to improve the current logic

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.