EAS building fails with package.json error

  • Whether you are bare or managed workflow
    Managed
  • Your eas-cli version
    eas-cli/2.7.0
    win32-x64
    node-v16.10.0
  • What you have tried so far
  • Clicked through every link on Google I could find (none mentioned this error specifically)
  • Read the Expo Documentation as well as Troubleshooting Guide
  • Ensured that the package.json is in the root directory

Error: package.json does not exist in /Users/expo/workingdir/build

I am building for iOS and having no issues up to the ‘Prepare Project’ phase. Each subsequent fails with the same error.

I have no idea where the ‘/Users/expo/workingdir/build’ directory actually is, as I don’t have an ‘expo’ user on my machine. Do I need to create these directories?

Hi @kmarmet

That’s on the build server. No, you do not need to create those directories on your local machine.

Do you by any chance have package.json in .gitignore?

Only files in your project folder that are not ignored in Git are uploaded to the build server

EAS Build builds your app like other CI services — in short, the entire project is uploaded securely to the cloud, then it is downloaded by a build server, the dependencies are installed, and the build is run (learn more). Everything needed to build your app must be included in the project that is uploaded. The default mechanism for packaging your project is roughly equivalent to git clone --depth 1, and so anything that is in your .gitignore will not be uploaded (learn more in “How projects are uploaded to EAS Build”).

Also:

What files are included in the archive?

You likely do not want to upload your node_modules directory, or maybe you have a .env file that is ignored by source control. EAS CLI always respects .gitignore files, but depending on your configuration there might be certain edge cases where EAS behavior is not 100% compliant with git.

You can run eas build:inspect --platform [ios|android] --stage archive --output ~/target/output/path --profile production and inspect the output directory (in this case ~/target/output/path) to see which files are included.

1 Like

I actually just very recently found a Github post that mentioned this issue and having package.json in the .gitignore. Which I did! I removed it and tried to rebuild but same error. Maybe I need to do something like push it back to Github to ensure the package.json exists?
Either way thank you so much for the first link, that is super helpful!

2 Likes

Try the eas build:inspect command to see what’s being included.

You don’t need to push to GitHub. package.json should be included as long as you don’t have it ignored.

Another thing: I don’t suppose this is a monorepo? There’s some info on those here:

Monorepos may require additional setup

2 Likes