How to Fix: .next folder not generating on mac m1 pro
If the .next folder never appears on a MacBook Pro M1 after running a fresh Next.js app, the problem is usually not that Next.js forgot to build. It is almost always caused by a broken local runtime setup: an unsupported Node.js version, a failed native dependency install, corrupted dependencies, or a dev server crash before compilation finishes.
Table of Contents
Understanding the Root Cause
The .next directory is generated by the Next.js compiler when the application successfully starts in development mode with next dev or builds with next build. If that folder is missing, one of these technical failures usually happened first:
- Node.js version mismatch: Newer Next.js versions require supported Node releases. If your system is using an older or incompatible version, the dev server may exit before writing build artifacts.
- Apple Silicon environment conflicts: On an M1/M2 Mac, mixing ARM-native Node with dependencies installed under Rosetta, or vice versa, can cause package resolution and binary issues.
- Dependency installation failure: If node_modules is incomplete or corrupted, Next.js cannot initialize the compiler pipeline.
- Silent startup crash: The app may fail during startup because of port conflicts, permissions, bad package manager lockfiles, or cached artifacts.
- Filesystem expectations: In development, the .next folder is generated only after the compiler begins running. If the process exits immediately, the folder may never appear.
In the linked reproduction project, the issue aligns most closely with an environment-level problem rather than application code. A clean starter created by create-next-app should generate .next automatically on first successful run.
Step-by-Step Solution
Follow these steps in order. Do not skip the environment checks.
1. Verify your Node.js version
Check the currently active version:
node -v
npm -v
If you are using an unsupported or unstable version, switch to a current LTS release. On macOS, the safest fix is using nvm.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
source ~/.zshrc
nvm install --lts
nvm use --lts
node -v
If your shell uses bash instead of zsh, reload the correct shell profile.
2. Confirm you are running native Apple Silicon tooling consistently
On an M1 Pro, make sure your terminal and Node installation are not mixed between ARM64 and Rosetta x64.
uname -m
node -p "process.arch"
Expected output should usually be:
arm64
arm64
If one shows x64 and the other environment is ARM-based, reinstall Node under the correct architecture using nvm.
3. Remove corrupted dependencies and lockfiles
Inside the project directory, clear existing installs:
rm -rf node_modules .next package-lock.json
npm cache clean --force
npm install
This forces a clean dependency tree and removes any stale build cache.
4. Start the app and watch for the first real compiler output
npm run dev
A healthy startup should show Next.js booting and compiling routes. Once compilation begins successfully, the .next folder should be created automatically.
5. If dev mode still fails, test a production build
This isolates whether the issue is specific to the dev server:
npm run build
If the build succeeds, .next will definitely be generated. If it fails, the terminal output usually reveals the actual blocker.
6. Check package scripts
Make sure your package.json contains valid Next.js scripts:
{
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
}
}
If those scripts were modified, restore them.
7. Recreate the app in a clean directory for comparison
If the original project still fails, create a brand-new app and compare results:
npx create-next-app@latest test-next-m1
cd test-next-m1
npm run dev
If the fresh app works, the original project has a local dependency or configuration issue. If both fail, the root problem is your system runtime.
8. Recommended stable setup for Mac M1 Pro
A reliable baseline is:
- Node.js LTS
- npm from that same Node install
- Terminal running as native ARM64
- Fresh node_modules install
- No mixed lockfiles from npm/yarn/pnpm unless intentionally managed
9. Final clean reset sequence
If you want the shortest full reset path, use this exact sequence:
nvm use --lts
rm -rf node_modules .next package-lock.json
npm cache clean --force
npm install
npm run dev
Common Edge Cases
- Rosetta terminal session: If iTerm or Terminal was launched under Rosetta, packages may install for x64 while your normal shell expects arm64.
- Permission issues: If the project folder is inside a protected or synced location, Next.js may fail to write build artifacts. Move the project to a normal local directory such as ~/Projects.
- Antivirus or filesystem sync tools: Aggressive file watchers can interfere with generated directories.
- Broken npm cache: Rare, but worth clearing when installs behave inconsistently.
- Port already in use: If startup fails before compilation, try another port.
npm run dev -- -p 3001
- Incompatible global tooling: A globally installed old next binary or custom shell alias can override expected behavior. Use the project-local script via npm run dev.
- Lockfile mismatch: Switching between npm, yarn, and pnpm can produce inconsistent installs. Keep one package manager per project.
FAQ
Why does .next only appear after running the app?
Because .next is a generated build output directory. It is created when next dev or next build successfully starts the compilation process.
Does deleting the .next folder break my app?
No. It is safe to delete because it is a cache/build artifact. Next.js recreates it on the next successful run.
Is this issue specific to Mac M1 Pro?
Not exclusively, but Apple Silicon systems are more likely to hit architecture mismatch problems when Node, Terminal, and dependencies are installed under mixed ARM and x64 environments.
The key takeaway is simple: if .next is missing, focus on why Next.js never completed startup. On a Mac M1 Pro, the fastest path to a fix is a clean Node LTS install, native ARM64 execution, a fresh dependency reinstall, and then rerunning npm run dev.