You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow to set a custom npm version with npm_version option #213
Hello!
npm is integrated to Node.JS.
NPM 7.x is integrated to Node.JS 15.x. If you specify Node.JS 15.x, NPM 7 will be selected. See details on https://nodejs.org/en/download/releases/
If you need npm 7 for previous versions of Node.JS, please consider upgrading it in runtime via npm install -g npm@latest
Reacted by loucadufault, sandstrom and HermannGruber
npm publish doesn't work with node 15.x in github actions:
npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in.
npm ERR! need auth You need to authorize this machine using `npm adduser`
Hello @mendrik , the issue with publishing is caused by updating npm to 7th version in node 15. The first minor and patch version of npm 7th had the issue with _auth. It was fixed in next versions. You can use npm with node 12th or upgrade npm to the latest one npm install -g npm@latest
Reacted by Andreas Herd, David Vurbs and Rico Kahler
Just like we have an option to use node versions, we should also have an option to choose npm versions
Reacted by Busticated, Jason Adams, Peter Juras, Felipe Castillo, parachvte, Nigel Jones, Thomas Mullen, Vladyslav Zubko, Johnson Liang, Jayden Seric and 85 more
Reacted by Joe Pea, Hui Chang, Daniel Lando, René Eschke, Dmitri, Pascal Betting, Param Siddharth, Ivan Coronado, yaeszlo, tystar and 8 more
Using npm install -g npm@latest with Github Actions gives errors regarding write-access permissions. Installing locally npm i npm@latest will change the repository and mess up any actions that depend on a clean git repo. Any ideas on how to fix this? How can I use npm@7 with node@14? Using node@15 is not an option, sorry...
Reacted by Kang Huang, Alex Bea, Dmitri and Dan Stanley
@smorimoto I don't know why I didn't think about it! So, running sudo i -g npm@latest after setup-node action does nothing...
Here's part of the log (can't provide a link to the full log because it's a private repo):
2021-03-10T18:20:25.6852244Z ##[group]Run sudo npm i -g npm@latest
2021-03-10T18:20:25.6852862Z sudo npm i -g npm@latest
2021-03-10T18:20:25.6906055Z shell: /usr/bin/bash -e {0}
2021-03-10T18:20:25.6906509Z env:
2021-03-10T18:20:25.6906931Z node-version: 14
2021-03-10T18:20:25.6907390Z ##[endgroup]
2021-03-10T18:20:37.6677894Z /usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
2021-03-10T18:20:37.6683622Z /usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js
2021-03-10T18:20:37.7550998Z + npm@7.6.2
2021-03-10T18:20:37.7552906Z added 59 packages from 24 contributors, removed 241 packages and updated 194 packages in 10.209s
2021-03-10T18:20:37.7743170Z ##[group]Run echo npm version "$(npm --version)"
2021-03-10T18:20:37.7743827Z echo npm version "$(npm --version)"
2021-03-10T18:20:37.7744307Z echo node version "$(node --version)"
2021-03-10T18:20:37.7790961Z shell: /usr/bin/bash -e {0}
2021-03-10T18:20:37.7791313Z env:
2021-03-10T18:20:37.7791661Z node-version: 14
2021-03-10T18:20:37.7792014Z ##[endgroup]
2021-03-10T18:20:38.3912711Z npm version 6.14.11
2021-03-10T18:20:38.3966163Z node version v14.16.0
You can see that after updating npm to version 7, GitHub Actions still uses version 6. Any ideas what to do?
I've never had to use sudo before when working with nvm. I'm wondering if updating npm with sudo did it for the system installed version and not the one used by nvm? In order to update the nvm one, we might need to run the command without sudo but that gives us errors about writing permissions...
SOLUTION: After some trial and error, I figure it out. Updating npm before using this action requires sudo but updating it after using this action doesn't require sudo. As I suspected, when running the command with sudo the system version gets updated, not the one use by this action. So for anybody having the same problem as me, make sure you update npm AFTER running this action and without using sudo
Reacted by Nelson Martell, Yehyoung Kang, Arun Reddy, AkshayRajput, Wildan M, Tom Zhang, Christopher Hirt, electrovir and José Pacheco
I suspect that the path priority is wrong. The following command should tell you the order, but it probably shows the one installed by the action at the top.
which --all npm
If it's true, you need to change the priority, but it can be a little tricky. For example, create a new directory, create a symbolic link to npm, and add it to the path through the Actions command.
SOLUTION: After some trial and error, I figure it out. Updating npm before using this action requires sudo but updating it after using this action doesn't require sudo. As I suspected, when running the command with sudo the system version gets updated, not the one use by this action. So for anybody having the same problem as me, make sure you update npm AFTER running this action and without using sudo
I don't actively switch npm versions and rely on the version installed with Node. Apparently, this isn't sufficient because my NX project works locally but fails in CI.
I found a solution in this Stack Overflow question: link
- run: npm update
However, I’m still unsure about which npm version I am actually using and would prefer to control it via the npm_version option.
I aslo believe it should be called pm_version, and it should also work for other package managers like Yarn.
Reacted by Mikey Gray, José Pacheco and Caio Augusto Araújo Oliveira
Thanks for the request and for the long-running discussion here.
setup-node provisions the Node.js toolchain, and npm comes bundled with each Node.js distribution. Pinning npm separately would make this action responsible for cache-key correctness, precedence against the packageManager field, and a Node-by-npm compatibility matrix. That's a significant expansion of scope for something already achievable in one step:
- uses: actions/setup-node@v7with:
node-version: '24'
- run: npm i -g npm@12 # or npm@latest, or npm@12.0.2 to pin exactly
This works for older majors as well as newer ones, and keeps the ordering explicit and visible in the workflow.
Given that, we're not planning to add an npm-version input. Closing as not planned, but happy to revisit if there's a case the workaround genuinely can't cover.
Reacted by fregante, Will Slattum and Nicky McCurdy
Activity
maxim-lobanov commentedon Dec 7, 2020
Hello!
npm is integrated to Node.JS.
NPM 7.x is integrated to Node.JS 15.x. If you specify Node.JS 15.x, NPM 7 will be selected. See details on https://nodejs.org/en/download/releases/
If you need npm 7 for previous versions of Node.JS, please consider upgrading it in runtime via
npm install -g npm@latestrobertsLando commentedon Dec 7, 2020
@maxim-lobanov Would it be possible to make it configurable like I suggested by using an option? It would allow to easily use matrix too
Use Node 15 with bundled npm 7, see actions/setup-node#213
smorimoto commentedon Dec 12, 2020
Is it not enough to add
npm_versionto the matrix and manipulate the workflow? I don't think it's a good idea to add more input than necessary.mendrik commentedon Dec 28, 2020
npm publish doesn't work with node 15.x in github actions:
when I downgrade to node 12 it works again
dmitry-shibanov commentedon Dec 29, 2020
Hello @mendrik , the issue with publishing is caused by updating npm to 7th version in node 15. The first minor and patch version of npm 7th had the issue with _auth. It was fixed in next versions. You can use npm with node 12th or upgrade npm to the latest one
npm install -g npm@latestFryuni commentedon Jan 15, 2021
It seems setting
node-version: 15now gets a release with the proper fix. It is working without having to update npmvinayakkulkarni commentedon Feb 16, 2021
Just like we have an option to use
nodeversions, we should also have an option to choosenpmversionsfcastilloec commentedon Mar 10, 2021
Using
npm install -g npm@latestwith Github Actions gives errors regarding write-access permissions. Installing locallynpm i npm@latestwill change the repository and mess up any actions that depend on a clean git repo. Any ideas on how to fix this? How can I use npm@7 with node@14? Using node@15 is not an option, sorry...smorimoto commentedon Mar 10, 2021
What about doing with sudo?
fcastilloec commentedon Mar 10, 2021
@smorimoto I don't know why I didn't think about it! So, running
sudo i -g npm@latestaftersetup-nodeaction does nothing...Here's part of the log (can't provide a link to the full log because it's a private repo):
You can see that after updating
npmto version 7, GitHub Actions still uses version 6. Any ideas what to do?I've never had to use
sudobefore when working withnvm. I'm wondering if updatingnpmwithsudodid it for the system installed version and not the one used by nvm? In order to update thenvmone, we might need to run the command withoutsudobut that gives us errors about writing permissions...SOLUTION: After some trial and error, I figure it out. Updating
npmbefore using this action requiressudobut updating it after using this action doesn't requiresudo. As I suspected, when running the command withsudothe system version gets updated, not the one use by this action. So for anybody having the same problem as me, make sure you updatenpmAFTER running this action and without usingsudosmorimoto commentedon Mar 10, 2021
I suspect that the path priority is wrong. The following command should tell you the order, but it probably shows the one installed by the action at the top.
If it's true, you need to change the priority, but it can be a little tricky. For example, create a new directory, create a symbolic link to npm, and add it to the path through the Actions command.
smorimoto commentedon Mar 10, 2021
Oh, it's good.
Bump node runtime on CI runners
Use npm ci again, but bump npm to v7 as recommended in actions/setup-…
29 remaining items
ci(npm): use Node 15 for running tests on CI
ci(npm): use Node 15 for running tests on CI
ci(npm): use Node 15 for running tests on CI
🔧 chore: try to fix release
chore(deps-dev): bump @typescript-eslint/eslint-plugin (actions#213)
[-]`npm_version` for npm 7 support[/-][+]`npm_version` for npm custom version support[/+][-]`npm_version` for npm custom version support[/-][+]Allow to set a custom npm version with `npm_version` option[/+]robertsLando commentedon Feb 8, 2024
@fregante Done
nickserv commentedon Feb 9, 2024
Note that Node is considering removing npm and having corepack install it, which would make this unnecessary if corepack was implemented.
TrejGun commentedon Jan 25, 2025
Hey, there!
On my local machine, I am using macOS with Node installed via NVM. In GitHub Actions, I use the following setup:
I don't actively switch npm versions and rely on the version installed with Node. Apparently, this isn't sufficient because my NX project works locally but fails in CI.
I found a solution in this Stack Overflow question: link
However, I’m still unsure about which npm version I am actually using and would prefer to control it via the
npm_versionoption.I aslo believe it should be called
pm_version, and it should also work for other package managers like Yarn.v-priyagupta108 commentedon Aug 31, 2026
Thanks for the request and for the long-running discussion here.
setup-nodeprovisions the Node.js toolchain, and npm comes bundled with each Node.js distribution. Pinning npm separately would make this action responsible for cache-key correctness, precedence against thepackageManagerfield, and a Node-by-npm compatibility matrix. That's a significant expansion of scope for something already achievable in one step:This works for older majors as well as newer ones, and keeps the ordering explicit and visible in the workflow.
Given that, we're not planning to add an
npm-versioninput. Closing as not planned, but happy to revisit if there's a case the workaround genuinely can't cover.