nextjs - 💡(How to fix) Fix Next.js create-next-app fails with npm on Windows (Node.js v22.19.0, EPERM cleanup error) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#85554Fetched 2026-04-08 02:15:05
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×2closed ×1commented ×1issue_type_added ×1

Error Message

npm warn cleanup Failed to remove some directories npm error EPERM: operation not permitted, rmdir ... npm error Error: Cannot find module 'D:\napi-postinstall\lib\cli.js' npm error 'Drizzle\Projects\nextjs-demo\node_modules.bin' is not recognized as an internal or external command

Root Cause

This issue occurs during the project creation process itself, before any files are generated. There is no reproducible repository because npx create-next-app fails during installation. However, you can reproduce it by simply running this command on Windows: npx create-next-app@latest nextjs-demo --yes in a directory that contains & in its path (for example: D:\Nextjs & Drizzle\Projects). Using the canary version also fails with the same result.

Fix Action

Fix / Workaround

Temporary workaround: Use pnpm or bun to create the project instead: pnpm create next-app nextjs-demo or bun create next-app nextjs-demo

Code Example

Provide environment information:

Operating System: Windows 10

Node.js version: v22.19.0

npm version: 10.x (default with Node 22)

create-next-app version: latest

Project path: D:\Nextjs & Drizzle\Projects\nextjs-demo

Reproducible with npm only; works fine with pnpm and bun.
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

This issue occurs during the project creation process itself, before any files are generated. There is no reproducible repository because npx create-next-app fails during installation. However, you can reproduce it by simply running this command on Windows: npx create-next-app@latest nextjs-demo --yes in a directory that contains & in its path (for example: D:\Nextjs & Drizzle\Projects). Using the canary version also fails with the same result.

To Reproduce

Open PowerShell on Windows (even as Administrator).

Navigate to a directory containing special characters such as & (for example: D:\Nextjs & Drizzle\Projects).

Run the command: npx create-next-app@latest nextjs-demo --yes

The installation process fails during dependency installation.

Errors observed include:

npm warn cleanup Failed to remove some directories

npm error EPERM: operation not permitted, rmdir ...

npm error Error: Cannot find module 'D:\napi-postinstall\lib\cli.js'

npm error 'Drizzle\Projects\nextjs-demo\node_modules.bin' is not recognized as an internal or external command

When using pnpm or bun instead of npm, the project installs successfully without any errors.

Current vs. Expected behavior

Current behavior:

Installation aborts midway with EPERM cleanup warnings and MODULE_NOT_FOUND errors.

npm fails to properly remove or access certain directories during dependency installation.

The issue occurs only when using npm/npx on Windows, especially with folders containing "&" in the path.

Expected behavior:

npx create-next-app should successfully create a new Next.js app regardless of npm version, Node.js version, or folder name.

The setup process should complete normally without EPERM or MODULE_NOT_FOUND errors.

Provide environment information

Provide environment information:

Operating System: Windows 10

Node.js version: v22.19.0

npm version: 10.x (default with Node 22)

create-next-app version: latest

Project path: D:\Nextjs & Drizzle\Projects\nextjs-demo

Reproducible with npm only; works fine with pnpm and bun.

Which area(s) are affected? (Select all that apply)

create-next-app

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

The issue seems to be related to npm’s cleanup process and Windows path handling when special characters (like &) are present. This might also be related to how Node.js 22 interacts with npm on Windows environments.

Temporary workaround: Use pnpm or bun to create the project instead: pnpm create next-app nextjs-demo or bun create next-app nextjs-demo

Both work without any issues.

extent analysis

TL;DR

Use pnpm or bun instead of npm to create the Next.js project to avoid issues with special characters in the directory path.

Guidance

  • The issue is likely caused by npm's inability to handle special characters like & in the directory path on Windows.
  • To verify, try creating the project in a directory without special characters using npx create-next-app.
  • As a temporary workaround, use pnpm create next-app nextjs-demo or bun create next-app nextjs-demo to create the project.
  • If using npm is required, consider updating the directory path to avoid special characters.

Example

No code snippet is necessary for this issue, as it's related to command-line usage and directory paths.

Notes

This issue seems to be specific to npm on Windows, particularly with Node.js version 22. Using pnpm or bun as a workaround is a safe and effective solution.

Recommendation

Apply workaround: Use pnpm or bun to create the project, as they do not have issues with special characters in the directory path.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING