aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.42k stars 2.12k forks source link

aws-amplify could not be found - Amplify import and awsconfig not working #8202

Closed Kevinberg closed 3 years ago

Kevinberg commented 3 years ago

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Authentication

Amplify Categories

auth

Environment information

I am receiving a syntax Error that aws-amplify could not be found within the project. When trying to import Amplify and awsmobile/exports from the src folder. I followed step by step the process described in AWS amplify's instructions till the amplify push part. See screenshots of my package.json , ``` # Put output below this line ![Screenshot 2021-04-29 at 22 11 12](https://user-images.githubusercontent.com/56350290/116613092-90f26700-a938-11eb-8225-5b675fca1736.png) ![Screenshot 2021-04-29 at 22 12 04](https://user-images.githubusercontent.com/56350290/116613095-918afd80-a938-11eb-8d86-55c5ae12b08a.png) ![Screenshot 2021-04-29 at 22 15 34](https://user-images.githubusercontent.com/56350290/116613097-92239400-a938-11eb-987f-23c53188ceaf.png) ``` ![Screenshot 2021-04-29 at 22 11 12](https://user-images.githubusercontent.com/56350290/116613092-90f26700-a938-11eb-8225-5b675fca1736.png) ![Screenshot 2021-04-29 at 22 12 04](https://user-images.githubusercontent.com/56350290/116613095-918afd80-a938-11eb-8d86-55c5ae12b08a.png) ![Screenshot 2021-04-29 at 22 15 34](https://user-images.githubusercontent.com/56350290/116613097-92239400-a938-11eb-987f-23c53188ceaf.png)

Screenshot 2021-04-29 at 22 25 25

Describe the bug

Hi There,

I am receiving a syntax Error that aws-amplify could not be found within the project. When trying to import Amplify and awsmobile/exports from the src folder.

I followed step by step the process described in AWS amplify's instructions till the amplify push part. See screenshots of my package.json ,

Expected behavior

Being able to import Amplify and awsmobile

Reproduction steps

All steps in the amplify docs

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line ```

aws-exports.js

/ eslint-disable / // WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.

const awsmobile = { "aws_project_region": "XXXX", "aws_cognito_identity_pool_id": "XXXXX", "aws_cognito_region": "XXXXX", "aws_user_pools_id": "XXXX", "aws_user_pools_web_client_id": "XXXX", "oauth": {} };

export default awsmobile;

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

Kevinberg commented 3 years ago

### aws.exports.js

/ eslint-disable / // WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.

const awsmobile = { "aws_project_region": XXXXX "aws_cognito_identity_pool_id": XXXXX", "aws_cognito_region": "XXXXX", "aws_user_pools_id": "XXXX", "aws_user_pools_web_client_id": "XXXX", "oauth": {} };

export default awsmobile;

Package.json

{ "name": "home", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint ." }, "dependencies": { "@aws-amplify/api": "^3.2.30", "@aws-amplify/pubsub": "^3.2.28", "@react-native-community/netinfo": "^6.0.0", "amazon-cognito-identity-js": "^4.6.0", "aws-amplify": "^3.3.27", "react": "17.0.1", "react-native": "0.64.0" }, "devDependencies": { "@babel/core": "^7.12.9", "@babel/runtime": "^7.12.5", "@react-native-community/eslint-config": "^2.0.0", "babel-jest": "^26.6.3", "eslint": "7.14.0", "jest": "^26.6.3", "metro-react-native-babel-preset": "^0.64.0", "react-test-renderer": "17.0.1" }, "jest": { "preset": "react-native" } }

App.js

import React from 'react'; import {Text, View, StyleSheet} from 'react-native'; import Amplify from 'aws-amplify'; import {Authenticator} from 'aws-amplify-react-native';

import awsmobile from './src/aws-exports'; Amplify.configure(awsmobile);

export default function App() { return (

Home

); }

const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', }, });

chrisbonifacio commented 3 years ago

Hi @Kevinberg ! 👋 Is this the documentation/tutorial you've been following to set up Amplify in a React Native project?

https://docs.amplify.aws/start/getting-started/installation/q/integration/react-native

Kevinberg commented 3 years ago

Hi @chrisbonifacio , Yes I did. Finally I was able to make it work, somehow my git stopped working. Thanks for your response!

chrisbonifacio commented 3 years ago

No problem! Glad you were able to figure it out :)

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.