next.js build error #168135
-
BodyHey everyone, I am getting this build error: > next-project@0.1.0 build
> next build
▲ Next.js 15.3.5
- Environments: .env
Creating an optimized production build ...
glob error [Error: EPERM: operation not permitted, scandir 'C:\Users\username\Application Data'] {
errno: -4048,
code: 'EPERM',
syscall: 'scandir',
path: 'C:\\Users\\username\\Application Data'
}
node:internal/process/promises:394
triggerUncaughtException(err, true /* fromPromise */);
^
[Error: EPERM: operation not permitted, scandir 'C:\Users\username\Application Data'] {
errno: -4048,
code: 'EPERM',
syscall: 'scandir',
path: 'C:\\Users\\username\\Application Data'
}
Node.js v22.11.0
Next.js build worker exited with code: 1 and signal: nullI already tried running that in Administrator in PowerShell inside anyone knows how to solve this ? Guidelines
|
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 3 replies
-
|
create a Then you can add this to your next.config.js Run with no-cache and it should resolve your issue. |
Beta Was this translation helpful? Give feedback.
-
|
This is a Windows permissions issue where Next.js is trying to scan restricted system directories. Here are several solutions: Quick Fixes (Try These First)• Run as Administrator - Right-click Command Prompt/PowerShell → "Run as administrator", then navigate to your project and run • Check Node.js permissions - Reinstall Node.js as administrator or use a Node version manager like • Clear caches - Run Project-Level Solutions• Add .nextignore - Create • Update next.config.js - Add webpack ignore patterns: /** @type {import('next').NextConfig} */
const nextConfig = {
webpack: (config) => {
config.watchOptions = {
...config.watchOptions,
ignored: [
'**/node_modules/**',
'**/Application Data/**',
'**/AppData/**'
]
}
return config
}
}
module.exports = nextConfigSystem-Level Solutions• Move project location - Avoid paths near system directories, use • Check antivirus - Temporarily disable real-time scanning or add project folder to exclusions • Windows Defender exclusion - Add your development folder to Windows Defender exclusions • Use WSL2 - Install Windows Subsystem for Linux and run your Next.js project there Environment Solutions• Use Docker - Containerize your build process to avoid Windows permission issues • Try different terminal - Use Git Bash, VS Code integrated terminal, or Windows Terminal The issue is Next.js trying to scan |
Beta Was this translation helpful? Give feedback.
-
|
🧰 Fix Steps Right-click → "Run as administrator" Then navigate to your project folder: bash Create a .nextignore file in your project root with: javascript js module.exports = nextConfig; bash |
Beta Was this translation helpful? Give feedback.
-
|
if you host in vercel |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
|
I had the same issue, and I was able to fix it by moving the project to the C: drive, deleting the .next and node_modules folders, and then reinstalling the packages. Reference: vercel/next.js#62281 (comment) |
Beta Was this translation helpful? Give feedback.
-
|
This error usually happens when a dependency or plugin tries to scan a directory like 🔧 Try these steps:
|
Beta Was this translation helpful? Give feedback.
-
|
I hope this will work as i got the same issue and it worked in mine 🛠 Step 1: Create
|
Beta Was this translation helpful? Give feedback.
-
|
Use a clean working directory like D:/next-project that doesn't sit inside a problematic user folder. Sometimes the issue happens if a package or script tries to glob files recursively from the home directory. |
Beta Was this translation helpful? Give feedback.
-
|
I tried many solutions, one (that worked) is: Install WSL (Ubuntu) and delete generator client {
provider = "prisma-client-js"
output = "../lib/generated/prisma"
binaryTargets = ["native", "debian-openssl-3.0.x"]
}and run pnpm install
pnpm build
pnpm prisma generatein WSL. This happened because Prisma Client was generated for "windows", but the actual deployment required "debian-openssl-3.0.x". Note:
|
Beta Was this translation helpful? Give feedback.
I tried many solutions, one (that worked) is:
Install WSL (Ubuntu) and delete
node_modulesand.nextand add following in your schema.prisma:and run
in WSL.
prisma generateis important otherwise it will throw error:This happened because Prisma Client was generated for "windows", but the actual deployment required "debian-openssl-3.0.x".
Note: