Can't find a variable atob
Solution 1
I have tried downgrading but that's not resulted as a solution to me. I don't know why.
The global import of base64 in the app.js resolved this problem.
import {decode, encode} from 'base-64'
if (!global.btoa) { global.btoa = encode }
if (!global.atob) { global.atob = decode }
Thanks for your responses.
Solution 2
Worked for me ! Thanks papay0, there is indeed something wrong with version 7.9.1.
npm install [email protected]
expo r -c # restard expo without cache
You can rm -rf ./node_modules/ && npm i
Solution 3
I found a workaround, I still there is a bug on their side. They just released 2 days ago version 7.9.1. Try to use 7.9.0.
yarn add [email protected]
I am creating an issue for it, follow here.
Solution 4
Thanks @Pradeep. This worked for me on firebase 7.14.1:
import {decode, encode} from 'base-64'
if (!global.btoa) { global.btoa = encode }
if (!global.atob) { global.atob = decode }
and using import like this
import firebase from 'firebase'; import 'firebase/firestore'
Pradeep
Working as a Mobile developer in Atithi Khana, a food delivery startup based on Chennai. Freelancing by managing and running my personal UI design and app development platform Bored Boy. Contact me for any app designs and developments or both. Always ready to collaborate with interesting people.
Updated on July 27, 2022Comments
-
Pradeep almost 2 years
Screen1.js
import React,{useEffect} from 'react' import {View,Text} from 'react-native' import * as firebase from 'firebase/app'; import '@firebase/firestore'; const Screen1 = props =>{ useEffect(() => { var dbh = firebase.firestore().collection("Jots").doc("note"); dbh.set({name:"pradeep"}) //The yellow warning is popped up in this line. }); return( <View> <Text>Title</Text> </View> ) }
console
[Unhandled promise rejection: ReferenceError: Can't find variable: atob] Stack trace: node_modules\@firebase\firestore\dist\index.cjs.js:23101:0 in <global> http://192.168.0.108:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:131203:60 in fromBase64String
I just followed the guide in the expo documentation but still don't know why this problem is occurring. Need a clear explanation on this. And also what is atob variable?
-
Pradeep over 4 yearsthanks for the response still the downgrading to the lower version doesn't help. It stillsays 'can't find variable atob'.
-
Pradeep over 4 yearsshould I wrap the JSON with atob?
-
Fernando Rojo about 4 yearsI upgraded but did nothing with firebase 7.9.3. This solution fixed it for me.
-
Mugen about 4 yearsalso got the same with
7.11.0
, answer resolves the issue -
Baptiste Arnaud about 4 yearsSame here with
7.14.0
-
lyrio about 4 yearsThanks a lot. This solution worked for me, while facing same issue with 7.14.0!
-
DiaMaBo about 4 yearsThank you for your code. This is my solution for this error.
-
0x4b50 about 4 yearsFor TypeScript I had to add
const globalAny: any = global;
to make it work and then use theglobalAny
field instead ofglobal
. -
Carrie M. about 4 yearsThis seems to be an issue again in firebase 7.14.3, only the above solution no longer remedies the problem