Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

npm on Windows fails because the AppData\Roaming\npm folder is missing

ErrorError: ENOENT, stat 'C:\Users\<user>\AppData\Roaming\npm'

Short answer

npm on Windows keeps global packages in the folder %AppData%\npm by default. If that folder does not exist, or the prefix points somewhere else, npm stops with ENOENT. Check the prefix with npm config get prefix, create the folder as your normal user, or set the prefix to a folder that exists.

  • Applies to Windows 11, Node.js 22, npm 10
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print the prefix npm uses for global packages and test whether that folder exists.

    npm config get prefix
    Test-Path "$env:APPDATA\npm"
  2. 2Match what you see, then jump to its fix

    1. 1Test-Path prints False and the error names C:\Users\<user>\AppData\Roaming\npm.The global folder was never createdFix
    2. 2npm config get prefix prints a path other than %AppData%\npm, such as a drive or a profile that was removed.The prefix points to a folder that does not existFix

What does the error look like?

  • Error: ENOENT, stat 'C:\Users\<user>\AppData\Roaming\npm'

Cause 1 of 2

The global folder was never created

1Check

The npm common-errors page lists this ENOENT stat error for that exact path and says the folder must exist and be writable by your normal user account.

Test-Path "$env:APPDATA\npm"
echo $env:APPDATA

2Fix

Create the folder in a normal (not administrator) PowerShell, so your user owns it.

New-Item -ItemType Directory -Force "$env:APPDATA\npm"

3Verify

Run the command that failed again, for example a global install.

Test-Path "$env:APPDATA\npm"
npm config get prefix

Confirmed by docs.npmjs.com

Did this fix it?

Cause 2 of 2

The prefix points to a folder that does not exist

1Check

The npm folders documentation says that on Windows the global prefix defaults to %AppData%\npm. A prefix set in an npmrc file overrides the default. npm config list shows what is set.

npm config list
npm config get prefix

2Fix

Delete the stale setting to return to the default, or set the prefix to a folder you created.

npm config delete prefix
# or point it at a folder that exists
npm config set prefix "$env:APPDATA\npm"

3Verify

The prefix is now a folder that exists.

npm config get prefix
Test-Path (npm config get prefix)

Confirmed by docs.npmjs.com

Did this fix it?

How do I stop it coming back?

  • Create global folders and run npm as your normal user, not as Administrator.
  • Keep prefix overrides in one npmrc file and write down why.
  • After moving or restoring a Windows profile, check the prefix once with npm config get prefix.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

ng serve says it cannot determine the project or target

Cannot determine project for command.

The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.

3 causes, each with a fix

Back end

ng serve cannot find the dev-server builder package

Could not find the implementation for builder @angular/build:dev-server

The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.