Has anyone ever gotten AWS Amplify DataStore working with EAS?

Following the documented steps for using AWS Amplify DataStore with JavaScript does not work with Expo (using eas build).

Following those instructions exactly, the simple code

import { Amplify } from 'aws-amplify'
import awsconfig from './aws-exports'

import { DataStore } from 'aws-amplify';

try {
  const data = await DataStore.query(TestData);
  console.log("Data retrieved successfully!", JSON.stringify(data, null, 2));
} catch (error) {
  console.log("Error retrieving data", error);

where TestData is defined in my schema.graphql, as described on the docs, results in the error:

Unexpected identifier '_awsAmplify'. Expected ';' after variable declaration.
at node_modules/metro-runtime/src/modules/HMRClient.js:106:4 in inject
at node_modules/metro-runtime/src/modules/HMRClient.js:115:2 in injectUpdate
at node_modules/metro-runtime/src/modules/HMRClient.js:183:20 in on$argument_1
at node_modules/metro-runtime/src/modules/vendor/eventemitter3.js:229:10 in emit
at node_modules/metro-runtime/src/modules/HMRClient.js:162:10 in _ws.onmessage
at node_modules/react-native/Libraries/WebSocket/WebSocket.js:229:8 in _eventEmitter.addListener$argument_1
at node_modules/react-native/Libraries/vendor/emitter/_EventEmitter.js:135:10 in EventEmitter#emit

The instructions also seem incomplete, as they mention “Initializing the Amplify DataStore” but don’t really explain how that is supposed to happen (which might be the problem?).

How do I get past this error and get DataStore working in my app? What are the actual steps to get it working?

In case it matters, I’m building using

eas build --profile development --platform ios --local

and running using

expo start --dev-client

starting with a simple TypeScript expo init project and having installed the required packages with

expo install aws-amplify aws-amplify-react-native
expo install @react-native-community/netinfo @react-native-async-storage/async-storage @react-native-picker/picker

and having confirmed that the app works fine with AWS Amplify GraphQL , e.g. with (instead of the above code)

import { Amplify } from 'aws-amplify'
import awsconfig from './aws-exports'

const listTestData = `
  query ListTestData(
    $filter: ModelTestDataFilterInput
    $limit: Int
    $nextToken: String
  ) {
    listTestData(filter: $filter, limit: $limit, nextToken: $nextToken) {
      items {
import { API, graphqlOperation } from 'aws-amplify'
API.graphql(graphqlOperation(listTestData, { filter: {},  limit: 50 })).then( f => console.log(f) )

to be clear - there is nothing magic about what EAS Build is doing to build your app - you can do a similar thing locally with expo run:ios which will generate the ios directory and then build it and launch the app (if you do this, you might want to clean up the generated files after: fyi/prebuild-cleanup.md at main · expo/fyi · GitHub). so if you are seeing this issue in this context, it is likely just an issue with either your amplify configuration or amplify and react-native itself. i’d recommend posting questions to the amplify discord or issues

Yes, true. I’m wondering though if someone else has gone through the steps in the Amplify DataStore docs using eas build with success. It seems like someone must have done, and have sorted what’s missing from the docs in the process.

I’m now starting to think that maybe no one has ever gotten AWS Amplify DataStore working with EAS build workflows?

Crickets —