Expo EAS Build iOS: EACCES: permission denied, mkdir 'node_modules' — tried everything, still stuck! #170527
-
Select Topic AreaQuestion BodyContext: I’m working on an Expo + React Native project (expo-router, nativewind, etc.), trying to build for iOS using EAS Build cloud services. When triggering a build using: eas build --platform ios --profile development-device …the build fails consistently with this error: npm error code EACCES ✅ What I’ve tried so far: Switched from npm to yarn: Error still occurs: EACCES: permission denied, mkdir '/Users/expo/workingdir/build/Sage/node_modules' Added the following env vars to eas.json (under development-device.ios.env): "env": { Added a eas-build-pre-install.js script to manually change permissions and install dependencies: const { execSync } = require("child_process"); console.log("🔧 Fixing permissions and installing dependencies..."); try { execSync("rm -rf node_modules", { stdio: "inherit" }); Confirmed I’m not using private packages Ran expo-doctor and fixed all issues except some known unmaintained packages Expo support asked me to try local iOS build, but I’m on Windows, so I cannot run: eas build --platform ios --profile development-device --local 🧪 Other details: The same build works fine when using the development profile (without developmentClient). Only iOS builds fail with the permission error. App builds fine locally (Android + iOS dev mode via simulator). No issues with lockfiles or node_modules locally. ❓Question: Has anyone seen this issue before with EAS iOS builds and node_modules permission errors? Is there something unique about the /Users/expo/workingdir/build/... environment that prevents mkdir? Do I need to explicitly sudo something differently in eas-build-pre-install.js? Is there an internal EAS bug or misconfiguration? Any recent changes to how iOS cloud workers are provisioned? Any tips, suggestions, or workarounds would be massively appreciated! 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
Hi , This looks like an environment-specific permissions issue with EAS iOS build workers rather than your project setup. The path What usually helps: Clean install via cache disable {
"build": {
"development-device": {
"ios": {
"env": {
"CI": "1",
"NPM_CONFIG_CACHE": "false"
},
"cache": {
"disabled": true
}
}
}
}
}
This forces EAS to reinstall node_modules in a fresh temp dir instead of hitting a cached layer with bad perms. Switch to Yarn / PNPM without sudo Prebuild instead of during build Known workaround "postinstall": "expo-yarn-workspaces clean && expo-yarn-workspaces check" Recommendation: If none of these work, I’d raise it as an EAS worker bug report with Expo support, since the mkdir permissions at /Users/expo/workingdir should be writable by default. |
Beta Was this translation helpful? Give feedback.
-
Yes, this is a known issue with EAS iOS builds where a permission conflict prevents the build from creating the Why It HappensThe EAS build for iOS runs on a dedicated macOS virtual machine. The user is The Solution: A Pre-Install ScriptThe most reliable solution is to explicitly adjust the directory permissions before the dependency installation begins. Your attempt with Here is an improved const { execSync } = require('child_process');
console.log("🔧 Forcing ownership and permissions before npm install...");
// Change ownership of the build directory to the 'expo' user.
// This ensures the user running the build has full control.
execSync("sudo chown -R expo:staff /Users/expo/workingdir/build", { stdio: "inherit" });
// Grant full read, write, and execute permissions to all users.
// This is a safe practice in the isolated, single-use EAS environment.
execSync("sudo chmod -R 777 /Users/expo/workingdir/build", { stdio: "inherit" });
console.log("✅ Permissions adjusted successfully.");
// Now, proceed with your original commands to clean and install.
execSync("rm -rf node_modules", { stdio: "inherit" });
execSync("npm install --legacy-peer-deps --unsafe-perm=true", { stdio: "inherit" });
console.log("📦 Dependencies installed successfully."); Steps to Implement the Solution
"scripts": {
"eas-build-pre-install": "node ./eas-build-pre-install.js"
} By adding this script, you are guaranteeing that the build environment has the necessary permissions to create the |
Beta Was this translation helpful? Give feedback.
Yes, this is a known issue with EAS iOS builds where a permission conflict prevents the build from creating the
node_modules
directory. The error,EACCES: permission denied, mkdir
, means the build process doesn't have the necessary write permissions.Why It Happens
The EAS build for iOS runs on a dedicated macOS virtual machine. The user is
expo
, and the working directory is/Users/expo/workingdir/build/
. While the environment is generally well-configured, a previous build step or cache issue can sometimes leave the project directory with incorrect permissions, preventing the package manager (like npm or yarn) from creating thenode_modules
folder. This is why the error is inconsistent an…