npm / npm/cli

[BUG] <title>On WIndows, npm 24 prefix defaults to "C:\Program Files\nodejs" which it doesn't have write permission

Open
#8,747 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Needs Triage
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Is there an existing issue for this?
  • I have searched the existing issues
This issue exists in the latest npm version
  • I am using the latest npm
Current Behavior
$ npm config get prefix
C:\Program Files\nodejs

$ npm config list
; node bin location = C:\Program Files\nodejs\node.exe
; node version = v24.11.1
; npm local prefix = C:\Users\pengc
; npm version = 11.6.2
; cwd = C:\Users\pengc
; HOME = C:\Users\pengc
; Run `npm config ls -l` to show all defaults.

this caused npm update -g to throw the following error:

npm update -g
npm error code EPERM
npm error syscall mkdir
npm error path C:\Program Files\nodejs\node_modules\.corepack-yRBjKBW1
npm error errno -4048
npm error Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_modules\.corepack-yRBjKBW1'
npm error     at async Object.mkdir (node:internal/fs/promises:861:10)
npm error     at async moveFile (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\fs\lib\move-file.js:27:3)
npm error     at async Promise.all (index 0)
npm error     at async moveFile (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\fs\lib\move-file.js:36:9)
npm error     at async Promise.allSettled (index 0)
npm error     at async [reifyPackages] (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:313:11)
npm error     at async Arborist.reify (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:125:5)
npm error     at async Update.exec (C:\Program Files\nodejs\node_modules\npm\lib\commands\update.js:64:5)
npm error     at async Npm.exec (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:208:9)
npm error     at async module.exports (C:\Program Files\nodejs\node_modules\npm\lib\cli\entry.js:67:5) {
npm error   errno: -4048,
npm error   code: 'EPERM',
npm error   syscall: 'mkdir',
npm error   path: 'C:\\Program Files\\nodejs\\node_modules\\.corepack-yRBjKBW1'
npm error }
npm error
npm error The operation was rejected by your operating system.
npm error It's possible that the file was already in use (by a text editor or antivirus),
npm error or that you lack permissions to access it.
npm error
npm error If you believe this might be a permissions issue, please double-check the
npm error permissions of the file and its containing directories, or try running
npm error the command again as root/Administrator.
npm error A complete log of this run can be found in: C:\Users\pengc\AppData\Local\npm-cache\_logs\2025-11-19T18_28_42_563Z-debug-0.log

Expected Behavior

default prefix should be "${USER_DIR}\AppData\Roaming\npm" on windows

Steps To Reproduce

install Node.js on windows

Environment
  • npm:
  • Node.js:
  • OS Name:
  • System Model Name:
  • npm config:
; node bin location = C:\Program Files\nodejs\node.exe
; node version = v24.11.1
; npm local prefix = C:\Users\pengc
; npm version = 11.6.2
; cwd = C:\Users\pengc
; HOME = C:\Users\pengc
; Run `npm config ls -l` to show all defaults.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported configuration with npm config get prefix and npm config list on Windows after installing Node.js. Trace where the default prefix is selected and verify that it resolves to the user's AppData\Roaming\npm directory rather than C:\Program Files\nodejs; confirm the fix by rerunning npm update -g without EPERM.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.