amplify-js: Error: evaluating 'global.TYPED_ARRAY_SUPPORT'
Do you want to request a feature or report a bug?
- a bug.
What is the current behavior?
- when I just do this:
import Amplify from 'aws-amplify';everything crashes and throws the following error:
05-08 09:53:31.345 6995 7117 E ReactNativeJS: undefined is not an object (evaluating 'global.TYPED_ARRAY_SUPPORT')
05-08 09:53:31.363 6995 7117 W ReactNativeJS: Unable to symbolicate stack trace: undefined is not an object (evaluating 'self.fetch')
05-08 09:53:31.364 6995 7117 E ReactNativeJS: Module AppRegistry is not a registered callable module (calling runApplication)
05-08 09:53:31.365 6995 7117 E ReactNativeJS: Requiring module "fetch", which threw an exception: TypeError: undefined is not an object (evaluating 'self.fetch')
05-08 09:53:31.367 6995 7117 W ReactNativeJS: Unable to symbolicate stack trace: Requiring module "fetch", which threw an exception: TypeError: undefined is not an object (evaluating 'self.fetch')
05-08 09:53:31.367 6995 7117 W ReactNativeJS: Unable to symbolicate stack trace: undefined is not an object (evaluating '_require2(_dependencyMap[0], 'fetch').fetch')
Here is a screenshot:
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn’t have dependencies other than AWS Amplify.
-
I did include my aws ressources as descriped in the docs with just one exceptions: I did remove the
RNPushNotificationPackagefrom my build as I do not need it. -
Like I said above, all I’ve done was just use this piece of code in my App.js:
import Amplify from 'aws-amplify'; -
Step by Step what I’ve done so far:
- included these dependencies in my package.json:
"dependencies": {
"aws-amplify": "^0.3.3",
"aws-amplify-react-native": "^0.2.9",
"moment": "^2.22.0",
"prop-types": "^15.6.1",
"react": "16.3.2",
"react-native": "0.55.3",
"react-native-check-box": "^2.1.0",
"react-navigation": "^2.0.0",
"react-redux": "^5.0.7",
"redux": "^4.0.0",
"amazon-cognito-identity-js": "^2.0.0",
"aws-sdk": "2.234.1",
"buffer": "^5.0.7",
"mime-type": "^3.0.5",
"path": "^0.12.7",
"react-devtools": "^3.2.1",
"react-native-elements": "^0.19.1",
"react-native-fetch-blob": "^0.10.8",
"react-native-prompt": "^1.0.0",
"react-native-uuid": "^1.4.9",
"react-native-vector-icons": "^4.3.0"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-jest": "22.4.3",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"babel-preset-react-native": "4.0.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-config-react-native": "^2.0.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.7.0",
"eslint-plugin-react-native": "^3.2.1",
"flow-bin": "^0.71.0",
"react-native-cli": "^2.0.1",
"jest": "22.4.3",
"react-test-renderer": "16.3.2"
}
- Used react-native link, to link all needed parts in android and ios.
- Removed aws-amplify from:
android\build.gradle,android\settings.gradle,android\app\build.gradle - Removed
RNPushNotificationPackagefrom:android\app\src\main\java\com\appname\MainApplication.java cd android\ && gradlew cleanresults:
Incremental java compilation is an incubating feature.
:amazon-cognito-identity-js:clean
:app:clean
:react-native-fetch-blob:clean
:react-native-vector-icons:clean
BUILD SUCCESSFUL
Total time: 11.577 secs
cd .. && react-native run-androidresults in a successful build as well (I spare you guys with the huge output).
What is the expected behavior?
- that the import works without an error.
Which versions of Amplify, and which browser / OS are affected by this issue? Did this work in previous versions?
- see in dependencies above
- I’m on windows
- I did not try any different versions BUT:
The example here: https://github.com/aws-samples/aws-mobile-react-native-starter was working as expected (with
"aws-amplify": "^0.2.4"). After some research and the reason that I did not want to inlcude firebase dependencies lead me to removeRNPushNotificationPackageandaws-amplifyfrom the above mentioned files.
You can turn on the debug mode to provide more info for us by setting window.LOG_LEVEL = 'DEBUG'; in your app.
- if needed tell me how to do it in react-native.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 27 (4 by maintainers)
Ok, after some testing today I can confirm that
Error: evaluating 'global.TYPED_ARRAY_SUPPORT'is 100% caused bybabel --presets envin combination withamazon-cognito-identity.js.I did change this:
To this:
Thanks to @AceNorth for confirming this.
Remember to completley rebuild your app and remove all temporary files to be clean:
C:\Users\Megajin\AppData\Local\Temp.node_modules.npm install --no-optional.set RNFB_ANDROID_PERMISSIONS=true(this is for the current session so I can link react-native-fetch-blob).react-native linkI guess the Issue can be closed as resolved @powerful23 @elorzafe
You guys might find this useful too: @paul-doherty @AndrewSouthpaw @michalziolkowski
Ok I found what my problem was. I was excluding node_modules in my tsconfig like below.
Turns out this doesn’t exclude it. I set my rootDir to force it to exclude node_modules and now all is good
Thanks
@powerful23 @paul-doherty
It is working now for me. I did the following:
C:\Users\Megajin\AppData\Local\Temp.node_modules.npm install --no-optional.set RNFB_ANDROID_PERMISSIONS=true(this is for the current session so I can link react-native-fetch-blob).react-native linkEverything works as expected, but I still do not know what the cause was. I recommend everyone having the same issue to follow my steps above and try a clean install of all packages. If the error still occurs try to remove packages one by one and start with your
devDependencies.I should mention that I did a gradle upgrade. I’ll provide my new updated sources for the android folder:
android\gradle\wrapper\gradle-wrapper.properties:android\build.gradle:android\settings.gradle:android\app\build.gradle:android\app\src\main\AndroidManifest.xml:android\app\src\main\java\com\appname\MainActivity.java:android\app\src\main\java\com\appname\MainApplication.java: