Windows: Cannot update global npm version after using setup-node
See original GitHub issueDescription:
Up until now, updating the global npm version after setting up the node version using npm install -g npm
worked on all operating systems without issues.
Now I’m receiving the following errors:
npm ERR! code EPERM
npm ERR! syscall rename
npm ERR! path C:\npm\prefix\node_modules\npm\node_modules\.node-gyp.DELETE\node_modules\@tootallnate
npm ERR! dest C:\npm\prefix\node_modules\npm\node_modules\node-gyp\node_modules\@tootallnate
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, rename 'C:\npm\prefix\node_modules\npm\node_modules\.node-gyp.DELETE\node_modules\@tootallnate' -> 'C:\npm\prefix\node_modules\npm\node_modules\node-gyp\node_modules\@tootallnate'
npm ERR! [OperationalError: EPERM: operation not permitted, rename 'C:\npm\prefix\node_modules\npm\node_modules\.node-gyp.DELETE\node_modules\@tootallnate' -> 'C:\npm\prefix\node_modules\npm\node_modules\node-gyp\node_modules\@tootallnate'] {
npm ERR! cause: [Error: EPERM: operation not permitted, rename 'C:\npm\prefix\node_modules\npm\node_modules\.node-gyp.DELETE\node_modules\@tootallnate' -> 'C:\npm\prefix\node_modules\npm\node_modules\node-gyp\node_modules\@tootallnate'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'rename',
npm ERR! path: 'C:\\npm\\prefix\\node_modules\\npm\\node_modules\\.node-gyp.DELETE\\node_modules\\@tootallnate',
npm ERR! dest: 'C:\\npm\\prefix\\node_modules\\npm\\node_modules\\node-gyp\\node_modules\\@tootallnate'
npm ERR! },
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'rename',
npm ERR! path: 'C:\\npm\\prefix\\node_modules\\npm\\node_modules\\.node-gyp.DELETE\\node_modules\\@tootallnate',
npm ERR! dest: 'C:\\npm\\prefix\\node_modules\\npm\\node_modules\\node-gyp\\node_modules\\@tootallnate',
npm ERR! parent: 'npm'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\npm\cache\_logs\2022-01-29T07_32_14_023Z-debug.log
Action version: 2.5.1 (pinned at @2)
Platform:
- Ubuntu
- macOS
- Windows
Runner type:
- Hosted
- Self-hosted
Tools version: Trying to set up node 12, likely also an issue with other node versions.
Repro steps:
You can see an example action run here. The failed workflow runs npm install -g npm
after using the setup-node
action, the passing run runs it without using the setup-node action.
Workflow configuration used in the example above:
name: github-actions-windows-npm-install-test
on:
push:
jobs:
win-setup-node-action:
name: "WIN: Global npm install with setup-node action"
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 12
- name: Install latest npm version
run: npm install --global npm
win-preinstalled-node:
name: "WIN: Global npm install without setup-node action"
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Install latest npm version
run: npm install --global npm
Expected behavior:
npm install -g npm
should globally install the newest npm version and overwrite the default version that comes with node 12, 14 etc.
Actual behavior:
npm install -g npm
fails due to permissions errors on Windows and breaks the workflow run.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:13
- Comments:10 (3 by maintainers)
Top GitHub Comments
Hello everyone. Thank you for your report. I think it should be related to this issue. As a workaround for now you can specify npm version as
8.3.1
.I ran into the same issue… installing 8.3.1 as a workaround worked for me.