Closed billzeng2k closed 3 years ago
Same issue is hapenning to us, the error comes from this import.
When replaced by import getRandomBase64 from './getRandomBase64.expo';
, everything works. Using managed workflow, Expo SDK 40.0.1 and same package versions as above.
I've tried to replicate the issue with the latest versions of Expo & Amplify, but I am not seeing any errors that you are showing. Would you be able to provide a small reproducible sample that shows the behavior?
Here is what I have:
I found that my metro.config.js file is most likely causing the bug
const MetroConfig = require('@ui-kitten/metro-config')
const defaultConfig = require('metro-config/src/defaults').getDefaultValues()
const evaConfig = {
evaPackage: '@eva-design/eva',
customMappingPath: './theme/mapping.json'
};
module.exports = MetroConfig.create(evaConfig, {
transformer: {
babelTransformerPath: require.resolve('react-native-svg-transformer'),
},
resolver: {
assetExts: defaultConfig.resolver.assetExts.filter(ext => ext !== 'svg'),
sourceExts: [...defaultConfig.resolver.sourceExts, 'svg']
},
});
When I remove the file the bug goes away
Edit: The login function breaks when I add the metro config from https://github.com/kristerkari/react-native-svg-transformer, otherwise it works fine. Is there anyway I can keep my metro config? If not I will find a work around
Can support this, have installed react-native-svg package and similar metro config
const {getDefaultConfig} = require('metro-config');
module.exports = (async () => {
const {
resolver: {sourceExts, assetExts},
} = await getDefaultConfig();
return {
transformer: {
babelTransformerPath: require.resolve('react-native-svg-transformer'),
},
resolver: {
assetExts: assetExts.filter(ext => ext !== 'svg'),
sourceExts: [...sourceExts, 'svg'],
},
};
})();
@billzeng2k I maybe found the solution, try replacing defaultConfig with
const defaultConfig = require('@expo/metro-config').getDefaultConfig(__dirname);
and let me know if it fixed the issue. You may also have to install @expo/metro-config
package as a dev dependency.
I have this similar too
Having this same error
error signing in [TypeError: (0, _getRandomBase.default) is not a function. (In '(0, _getRandomBase.default)(array.byteLength)', '(0, _getRandomBase.default)' is undefined)]
to reproduce:
{ "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", "test": "jest --watchAll" }, "jest": { "preset": "jest-expo" }, "dependencies": { "@expo-google-fonts/muli": "^0.1.0", "@expo/vector-icons": "^12.0.0", "@highcharts/highcharts-react-native": "^3.1.3", "@react-native-community/datetimepicker": "^3.0.9", "@react-native-community/masked-view": "0.1.10", "@react-native-community/netinfo": "^5.9.7", "@react-navigation/bottom-tabs": "^5.8.0", "@react-navigation/native": "^5.7.3", "@react-navigation/stack": "^5.9.0", "@reduxjs/toolkit": "^1.5.0", "amazon-cognito-identity-js": "^4.5.1", "aws-amplify": "^3.3.24", "aws-amplify-react-native": "^4.3.2", "expo": "^40.0.0", "expo-asset": "~8.2.1", "expo-constants": "~9.3.3", "expo-font": "~8.4.0", "expo-linear-gradient": "~8.4.0", "expo-linking": "~2.0.1", "expo-splash-screen": "~0.8.1", "expo-status-bar": "~1.0.3", "expo-web-browser": "~8.6.0", "gh-pages": "^3.1.0", "lodash": "^4.17.20", "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-calendars": "^1.1128.0", "react-native-datepicker": "^1.7.2", "react-native-gesture-handler": "~1.8.0", "react-native-iphone-x-helper": "^1.3.1", "react-native-maps": "0.27.1", "react-native-reanimated": "~1.13.0", "react-native-redash": "^16.0.4", "react-native-safe-area-context": "3.1.9", "react-native-screens": "~2.15.2", "react-native-svg": "^12.1.0", "react-native-web": "~0.13.12", "react-native-webview": "11.0.0", "react-redux": "^7.2.2", "redux": "^4.0.5", "redux-thunk": "^2.3.0" }, "devDependencies": { "@babel/core": "~7.9.0", "@types/react": "~16.9.35", "@types/react-native": "~0.63.2", "@types/react-native-calendars": "^1.505.0", "@types/react-native-datepicker": "^1.7.0", "@types/react-redux": "^7.1.15", "jest-expo": "^40.0.0", "typescript": "~4.0.0" }, "private": true }
const { getDefaultConfig } = require("metro-config"); module.exports = (async () => { const { resolver: { sourceExts, assetExts }, } = await getDefaultConfig(); return { transformer: { getTransformOptions: async () => ({ transform: { experimentalImportSupport: false, inlineRequires: false, }, }), }, resolver: { sourceExts, assetExts: [...assetExts, "hcscript"], }, }; })();
{ "compilerOptions": { "allowSyntheticDefaultImports": true, "jsx": "react-native", "lib": ["dom", "esnext"], "moduleResolution": "node", "noEmit": true, "skipLibCheck": true, "resolveJsonModule": true, "strict": true, "baseUrl": ".", "paths": { "*": ["src/*"], "@components/*": ["src/components/*"], "@container/*": ["src/container/*"], "@configs/*": ["src/configs/*"], "@navigations/*": ["src/navigations/*"], "@images/*": ["src/images/*"], "@configs": ["src/configs/index"], "@store/*": ["src/store/*"], "react-native-redash/lib/module/v1": [ "./node_modules/react-native-redash/lib/typescript/v1/index.d.ts" ] }, }, }
module.exports = function (api) { api.cache(true); return { presets: ["babel-preset-expo"], plugins: [ [ "module-resolver", { root: ["./src"], extensions: [".ios.js", ".android.js", ".js", ".ts", ".tsx", ".json"], alias: { "@components": "./src/components", "@components/*": ["src/components/*"], "@container/*": ["src/container/*"], "@configs/*": ["src/configs/*"], "@navigations/*": ["src/navigations/*"], "@images/*": ["src/images/*"], "@configs": ["src/configs/index"], "@configs": ["src/configs/index"], "@store/*": ["./src/store/*"], }, }, ], ], }; };
i had the similar issue. @xgallom how do you fix the import getRandomBase64 from './getRandomBase64.expo' issue? is this cause the issue?
@billzeng2k did you fixed the issue? is it metro.config.js caused it?
You need to getDefaultConfig from @expo/metro-config not from metro-config.
As I mentioned above, try using const defaultConfig = require('@expo/metro-config').getDefaultConfig(__dirname);
instead
Thank you for the answer. I have deleted the original question because I thought I should have tried the solution that was already posted as mentioned. I did tried that and didn't work, or at least I am not able to configure the file correctly. I tried several things but honestly I am not sure how to use the defaultConfig, and nothing I tried worked.
const { getDefaultConfig } = require('@expo/metro-config');
const defaultConfig = getDefaultConfig(__dirname); // what do I do with this now?
const blacklist = require('metro-config/src/defaults/blacklist');
module.exports = (async () => {
return {
resolver: {
blacklistRE: blacklist([/#current-cloud-backend\/.*/]),
},
};
})();
To get me going I have manually changed the import in the file node_modules\amazon-cognito-identity-js\src\utils\getRandomValues.native.js to include the one with the expo extension.
Looks like the same issue here: https://github.com/aws-amplify/amplify-js/issues/8113
Can you try again with the EXPO_LEGACY_IMPORTS=1
environment variable?
We were also having this problem, I tried @xgallom's solution (thanks btw :taco: ) and it seems like a fix. Here are the steps I followed:
npm install @expo/metro-config --save-dev
getDefaultConfig
from metro-config
to @expo/metro-config
__dirname
argument to getDefaultConfig
Here is our metro.config.js
file now:
const { getDefaultConfig } = require('@expo/metro-config');
module.exports = (async () => {
const {
resolver: { sourceExts, assetExts }
} = await getDefaultConfig(__dirname);
return {
transformer: {
babelTransformerPath: require.resolve('react-native-svg-transformer')
},
resolver: {
assetExts: assetExts.filter(ext => ext !== 'svg'),
sourceExts: [...sourceExts, 'svg']
}
};
})();
@marziamura can give this a try, if you're still getting the error.
thanks @svidgen your fix worked at least with expo start.
This issue is only happening on Android for me.
Expo CLI 4.4.3 environment info: System: OS: macOS 10.15.7 Shell: 3.2.57 - /bin/bash Binaries: Node: 10.16.3 - /usr/local/bin/node npm: 6.14.5 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2 Android SDK: API Levels: 25, 26 Build Tools: 23.0.1, 23.0.3, 25.0.0, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 27.0.1, 27.0.3 System Images: android-25 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom IDEs: Android Studio: 3.0 AI-171.4443003 Xcode: 11.5/11E608c - /usr/bin/xcodebuild npmPackages: expo: ^41.0.0 => 41.0.1 react: 16.13.1 => 16.13.1 react-dom: 16.13.1 => 16.13.1 react-native: https://github.com/expo/react-native/archive/sdk-41.0.0.tar.gz => 0.63.2 react-native-web: ~0.13.12 => 0.13.18 react-navigation: ^4.4.0 => 4.4.4 npmGlobalPackages: expo-cli: 4.4.3 Expo Workflow: managed
An update on this tread: none of the fix above seems to be working with expo:publish (other than manually changing the include) I did not try on a production build, and given the review times of the stores, I am not going to do that.
@mikeRChambers610 Could you also share what version of aws-amplify
you are using? We just published a new version yesterday that includes the changes for this issue.
@marziamura Could you describe what issue you are seeing with expo:publish
as it relates to Amplify? Also, are you using the latest version of aws-amplify
?
@amhinson I was also seeing this issue and updating from 3.3.27
to 3.4.1
resolved the issue for me.
@billzeng2k,
We are going to close this issue since we have not heard from you.
Please let us know if you are still needing support, provide steps to reproduce, and we can reopen the issue to investigate further.
Thanks
@billzeng2k,
We are going to close this issue since we have not heard from you.
Please let us know if you are still needing support, provide steps to reproduce, and we can reopen the issue to investigate further.
Thanks
@billzeng2k I didn't reply because every time I update amplify version something goes belly up, so I needed to set aside some time. I did it yesterday (and things did break big time), but unfortunately the problem still persists.
The problem is always the same, during the build the required expo file is not included, unless I change the source code manually.
in file
...\node_modules\amazon-cognito-identity-js\src\utils\getRandomValues.native.js
` import base64Decode from 'fast-base64-decode'; import getRandomBase64 from './getRandomBase64.expo'; ////<<< I change this manually
class TypeMismatchError extends Error {} class QuotaExceededError extends Error {} `
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.
Describe the bug When I use the function Auth.signIn it gives me error
[TypeError: (0, _getRandomBase.default) is not a function. (In '(0, _getRandomBase.default)(array.byteLength)', '(0, _getRandomBase.default)' is undefined)]
Only this function produces an error, Sign Up and Federated Sign In both work perfectlyTo Reproduce Steps to reproduce the behavior:
Initialize an expo project by following steps on https://docs.amplify.aws/lib/auth/getting-started/q/platform/js and call the Auth.signIn command
Expected behavior I expect to sign in or an error
Code Snippet package.json
Smartphone (please complete the following information):