Fastlane build failed with unknown error.

Hello, I am trying to build an app using EAS. The regular expo build was successful, but not eas build.

Here is my error. It obviously has something to do with the react-native-cheerio package I am using. However, I do not have any issues when creating standalone apps using Xcode on my iPhone. Can anyone offer any insights? Error below:

› Executing Showfolio » Bundle React Native code and images
    the transform cache was reset.

❌  error: File /Users/expo/Library/Developer/Xcode/DerivedData/Showfolio-gcojmkjetdjpshbeuqwspoawmjpu/Build/Intermediates.noindex/ArchiveIntermediates/Showfolio/BuildProductsPath/Release-iphoneos/showfolio.app/main.jsbundle does not exist. This must be a bug with


❌ Metro encountered an error:
Unable to resolve module react-native-cheerio from /Users/expo/workingdir/build/src/screens/Home.js: react-native-cheerio could not be found within the project.

If you are sure the module exists, try these steps:
 1. Clear watchman watches: watchman watch-del-all
 2. Delete node_modules and run yarn install
 3. Reset Metro's cache: yarn start --reset-cache
 4. Remove the cache: rm -rf /tmp/metro-*
   6 | import { showMessage, hideMessage } from "react-native-flash-message";
   7 | import { ThemeContext } from '../../theme-context';
>  8 | import cheerio from 'react-native-cheerio';
     |                      ^
   9 | import htmlparser2 from 'htmlparser2'
  10 | import axios from 'axios';
  11 | import api from '../API';
› Generating debug Showfolio » showfolio.app.dSYM
▸ ** ARCHIVE FAILED **
▸ The following build commands failed:
▸ 	PhaseScriptExecution Bundle\ React\ Native\ code\ and\ images /Users/expo/Library/Developer/Xcode/DerivedData/Showfolio-gcojmkjetdjpshbeuqwspoawmjpu/Build/Intermediates.noindex/ArchiveIntermediates/Showfolio/IntermediateBuildFilesPath/Showfolio.build/Release-iphoneos/Showfolio.build/Script-00DD1BFF1BD5951E006B06BC.sh
▸ (1 failure)
** ARCHIVE FAILED **
The following build commands failed:
	PhaseScriptExecution Bundle\ React\ Native\ code\ and\ images /Users/expo/Library/Developer/Xcode/DerivedData/Showfolio-gcojmkjetdjpshbeuqwspoawmjpu/Build/Intermediates.noindex/ArchiveIntermediates/Showfolio/IntermediateBuildFilesPath/Showfolio.build/Release-iphoneos/Showfolio.build/Script-00DD1BFF1BD5951E006B06BC.sh
(1 failure)
Exit status: 65
+-------------+-------------------------+
|           Build environment           |
+-------------+-------------------------+
| xcode_path  | /Applications/Xcode.app |
| gym_version | 2.185.1                 |
| sdk         | iPhoneOS14.5.sdk        |
+-------------+-------------------------+

And the Xcode error:

cheerio from /Users/expo/workingdir/build/src/screens/Home.js: react-native-cheerio could not be found within the project.

If you are sure the module exists, try these steps:
 1. Clear watchman watches: watchman watch-del-all
 2. Delete node_modules and run yarn install
 3. Reset Metro's cache: yarn start --reset-cache
 4. Remove the cache: rm -rf /tmp/metro-*
e[0m e[90m  6 |e[39m e[36mimporte[39m { showMessagee[33m,e[39m hideMessage } e[36mfrome[39m e[32m"react-native-flash-message"e[39me[33m;e[39me[0m
e[0m e[90m  7 |e[39m e[36mimporte[39m { e[33mThemeContexte[39m } e[36mfrome[39m e[32m'../../theme-context'e[39me[33m;e[39me[0m
e[0me[31me[1m>e[22me[39me[90m  8 |e[39m e[36mimporte[39m cheerio e[36mfrome[39m e[32m'react-native-cheerio'e[39me[33m;e[39me[0m
e[0m e[90m    |e[39m                      e[31me[1m^e[22me[39me[0m
e[0m e[90m  9 |e[39m e[36mimporte[39m htmlparser2 e[36mfrome[39m e[32m'htmlparser2'e[39me[0m
e[0m e[90m 10 |e[39m e[36mimporte[39m axios e[36mfrome[39m e[32m'axios'e[39me[33m;e[39me[0m
e[0m e[90m 11 |e[39m e[36mimporte[39m api e[36mfrome[39m e[32m'../API'e[39me[33m;e[39me[0m
    at ModuleResolver.resolveDependency (/Users/expo/workingdir/build/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:191:15)
    at DependencyGraph.resolveDependency (/Users/expo/workingdir/build/node_modules/metro/src/node-haste/DependencyGraph.js:353:43)
    at Object.resolve (/Users/expo/workingdir/build/node_modules/metro/src/lib/transformHelpers.js:271:42)
    at resolve (/Users/expo/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:571:33)
    at /Users/expo/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:587:26
    at Array.reduce (<anonymous>)
    at resolveDependencies (/Users/expo/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:586:33)
    at /Users/expo/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:275:33
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/Users/expo/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:87:24)
+ [[ false != true ]]
+ [[ ! -f /Users/expo/Library/Developer/Xcode/DerivedData/Showfolio-gcojmkjetdjpshbeuqwspoawmjpu/Build/Intermediates.noindex/ArchiveIntermediates/Showfolio/BuildProductsPath/Release-iphoneos/showfolio.app/main.jsbundle ]]
+ echo 'error: File /Users/expo/Library/Developer/Xcode/DerivedData/Showfolio-gcojmkjetdjpshbeuqwspoawmjpu/Build/Intermediates.noindex/ArchiveIntermediates/Showfolio/BuildProductsPath/Release-iphoneos/showfolio.app/main.jsbundle does not exist. This must be a bug with'
error: File /Users/expo/Library/Developer/Xcode/DerivedData/Showfolio-gcojmkjetdjpshbeuqwspoawmjpu/Build/Intermediates.noindex/ArchiveIntermediates/Showfolio/BuildProductsPath/Release-iphoneos/showfolio.app/main.jsbundle does not exist. This must be a bug with
+ echo 'React Native, please report it here: https://github.com/facebook/react-native/issues'
React Native, please report it here: https://github.com/facebook/react-native/issues
+ exit 2
                 Welcome to React Native!
                Learn once, write anywhere


Error: @build-script-error-begin
Error loading assets JSON from Metro. Ensure you've followed all expo-updates installation steps correctly. Unable to resolve module react-native-cheerio from /Users/expo/workingdir/build/src/screens/Home.js: react-native-cheerio could not be found within the project.

If you are sure the module exists, try these steps:
 1. Clear watchman watches: watchman watch-del-all
 2. Delete node_modules and run yarn install
 3. Reset Metro's cache: yarn start --reset-cache
 4. Remove the cache: rm -rf /tmp/metro-*
e[0m e[90m  6 |e[39m e[36mimporte[39m { showMessagee[33m,e[39m hideMessage } e[36mfrome[39m e[32m"react-native-flash-message"e[39me[33m;e[39me[0m
e[0m e[90m  7 |e[39m e[36mimporte[39m { e[33mThemeContexte[39m } e[36mfrome[39m e[32m'../../theme-context'e[39me[33m;e[39me[0m
e[0me[31me[1m>e[22me[39me[90m  8 |e[39m e[36mimporte[39m cheerio e[36mfrome[39m e[32m'react-native-cheerio'e[39me[33m;e[39me[0m
e[0m e[90m    |e[39m                      e[31me[1m^e[22me[39me[0m
e[0m e[90m  9 |e[39m e[36mimporte[39m htmlparser2 e[36mfrome[39m e[32m'htmlparser2'e[39me[0m
e[0m e[90m 10 |e[39m e[36mimporte[39m axios e[36mfrome[39m e[32m'axios'e[39me[33m;e[39me[0m
e[0m e[90m 11 |e[39m e[36mimporte[39m api e[36mfrome[39m e[32m'../API'e[39me[33m;e[39me[0m
@build-script-error-end

clone your project to a new directory and install dependencies then build in xcode, you will find it has the same error. you probably have some state in your project that isn’t in git

Thanks for the reply. I did as you said and did have the same error. However, running expo add react-native-cheerio resolved the problem and I can now successfully build the app.

you probably have some state in your project that isn’t in git

I don’t know what this means. Why would git have anything to do with this?

Thank you for the reply.

I don’t know what this means. Why would git have anything to do with this?

We are only uploading files tracked by git to the remote worker, stuff like node_modules, build directories and everything else from .gitignore is skipped

1 Like

Then it seems that your node_modules were out of sync with your dependencies in package.json for some reason.

1 Like

I guess I’m just confused. This is my current .gitignore file. It includes node_modules, obviously.

Screen Shot 2021-08-03 at 1.18.00 AM

So the problem is that for whatever reason, if I create a new project and then clone the git repo for my app, the app will encounter and error when building because react-native-cheerio is missing from the modules, even though the build process should be creating that module by pulling it from my package.json file, right? To remedy this issue locally, I can just run expo add react-native-cheerio and then reload the project and it opens up just fine. The EAS build process obviously don’t attempt that fix.

Screen Shot 2021-08-03 at 1.24.49 AM

I looked at the log for my build (specifically the run-fastlane part) and it doesn’t show the react-native-cheerio package being compiled, even though it’s very clearly listed in the package.json file.

So… my question is… how do I proceed? The file is obviously in there and will run locally if I just manually type expo add react-native-cheerio, so I’m totally unsure of what I need to do to get this to work.

I really appreciate your help and the other comments, do you have any advice for me?

edit: I found this in the Xcode logs:

I went to see what the deal was with the package.json file and lo-and-behold it’s right there, so I have no idea why Xcode can’t find the file?? Thoughts?

Screen Shot 2021-08-03 at 1.52.21 AM

Update: the build failed

If you have to do that in order for it to build it implies that your package.json in Git does not contain react-native-cheerio. e.g. what do you get if you do this in the root of the project:

git show package.json | grep react-native-cheerio

I suspect it will show nothing.

If that’s the case, then after running expo install react-native-cheerio, run:

git commit package.json package-lock.json

or if you use yarn:

git commit package.json yarn.lock

Then EAS Build will know to install react-native-cheerio into node_modules before building your app.

Thanks for the response wodin. I did what you suggested. Indeed the git show package.json | grep react-native-cheerio did not return anything (seen in screenshot). I then ran expo install react-native-cheerio even though it’s already installed. Then I did the git commit package.json yarn.lock which returned back

On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean

Here’s a screenshot.

I’m ignorant to this but it doesn’t seem like that would have worked. However I will still attempt to use eas build and report back on if it worked.

I really really really really appreciate y’all taking the time to help me with this issue. This kinda stuff stresses me out so much so I can’t even begin to show my gratitude.

I don’t think I replied to your comment in my previous comment, so I’m replying in this one to make sure you recieve a ping.

Sorry, I forgot to mention you need:

git add package.json yarn.lock

before you commit. i.e. what I’m saying is you need to commit the version of package.json and yarn.lock that contain react-native-cheerio to Git so that EAS Build will know to install it.

I will try that out and see what happens. Could you explain why the package.json file isn’t being updated in git? It’s not in my gitignore.

How do you normally commit your changes? Is it possible that you just never committed your most recent change?

What does git status give you?

What does git log -G react-native-cheerio package.json give you?