Publish a React Native App to cloud using AWS Amplify

Viewed 423

I want to write a react native front end application that calls a Lambda API and I'm trying to publish to cloud using AWS Amplify. In order to make sure I'm doing the correct steps I followed the Amplify documentation (https://docs.amplify.aws/start/getting-started/data-model/q/integration/react-native#create-a-graphql-api-and-database) but when I try to run "amplify publish" it returns an error like "Publish started for amplifyhosting npm ERR! missing script: build" .

package.json

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@react-native-community/netinfo": "^5.9.10",
    "aws-amplify": "^3.3.15",
    "aws-amplify-react-native": "^4.3.1",
    "expo": "~40.0.0",
    "expo-status-bar": "~1.0.3",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz",
    "react-native-web": "~0.13.12"
  },
  "devDependencies": {
    "@babel/core": "~7.9.0"
  },
  "private": true
}

I've noticed that I am missing build script but from what I've seen others didn't have it either, but it still worked for them. I don't know how should it look either, if I add it.

The second approach was through AWS Amplify console where I added the app from GitLab with the default settings but it returns and error on the build step from Cloud Formation. "Embedded stack arn:aws:cloudformation:-eu-central-1:stackaname was not successfully created: The following resource(s) failed to create: [AmplifyBranch]."

Thank you.

1 Answers

I encountered the exact same issue.

You can add "build": "expo build:web" to the package.json, it will solve the problem.

The package.json should be like this:

 "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject",
    "build": "expo build:web"
  },
Related