npm / npm/cli

[BUG] Updating global npm to 11.5.2 corrupts installation on Windows

Open
#8,480 4 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

When updating the global npm package from version 11.5.1 to 11.5.2 using the command npm install -g npm@11.5.2 on Windows, the npm installation becomes corrupted. The update command itself reports success ("added 1 package"), but any subsequent npm command fails with a MODULE_NOT_FOUND error.

The error log indicates a malformed path lookup:

Error: Cannot find module 'C:\Users\Yox\AppData\Roaming\npm\node_modules\npm\bin\node_modules\npm\bin\npm-prefix.js'
Expected Behavior

The command npm install -g npm@11.5.2 should successfully update the global npm package from version 11.5.1 to 11.5.2. After the update, running npm -v should correctly report 11.5.2 and all other npm commands should function normally.

Steps To Reproduce
  1. Install latest version of Nodejs winget install nodejs
  2. Verify the current npm version by running npm -v. It should output 11.5.1.
  3. Run the global update command for a specific newer version: npm install -g npm@11.5.2.
  4. Observe that the command reports success (e.g., "added 1 package").
  5. Attempt to check the npm version again by running npm -v.
  6. Observe that the command now fails with the MODULE_NOT_FOUND error.
Environment
  • npm -v:

    • Before update: 11.5.1
    • After update: Command fails with MODULE_NOT_FOUND.
  • node -v: v24.5.0

  • OS: Windows 11 Pro Insider Preview x86_64 (Build 27909.1000)

  • Host: ASUS ROG Strix G733ZW

  • CPU: 12th Gen Intel Core i9-12900H

  • GPU: NVIDIA GeForce RTX 3070 Ti Laptop GPU

  • Shell: PowerShell 7.5.2

  • Terminal: Windows Terminal 1.22.12111.0

  • npm config ls (before update):

    ; "builtin" config from C:\Program Files\nodejs\node_modules\npm\npmrc
    prefix = "C:\\Users\\Yox\\AppData\\Roaming\\npm"
    ; node bin location = C:\Program Files\nodejs\node.exe
    ; node version = v24.5.0
    ; npm local prefix = C:\Users\Yox
    ; npm version = 11.5.1
    ; cwd = C:\Users\Yox
    ; HOME = C:\Users\Yox
    ; Run `npm config ls -l` to show all defaults.
    
  • npm config ls (after update):

    • This command fails with the same MODULE_NOT_FOUND error.

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 failure with npm install -g npm@11.5.2 on Windows, then inspect the npm CLI's global installation and Windows path-handling entry points. Done means the update completes without corrupting the installation, npm -v reports 11.5.2, and subsequent npm commands no longer produce the MODULE_NOT_FOUND path.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.