Skip to content

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

@tribbloid

Description

@tribbloid

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next steps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions