-
-
Notifications
You must be signed in to change notification settings - Fork 794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recently installed in an Expo 37/RN app, getting TypeError: null is not an object (evaluating 'RNGetRandomValues.getRandomBase64') #207
Comments
Thanks for the report. I will be able to look only tomorrow because I am going to sleep. In a quick look, you have some problem with |
My mistake sorry, on further investigation I see this library only works in a bare RN project, and I am building this with Expo, therefore I'm pretty sure that is where the issue is. So you can probably ignore this.... sorry about that! |
It was still good that you opened this issue. As I mentioned in my article every issue should change code or docs to avoid the same mistakes in the future. Let’s improve docs. What is the solution for Expo? |
Well its strange, I have two projects, one that uses uuidV4 which is working fine, and I have pretty much cloned that one (but removed a native-base UI dependency that I was barely using) and now that one is throwing errors along these lines: uuidjs/uuid#375 The strange thing is I have compared the package.json of each package and the only difference is is Expo 37.0.3 as opposed to 37.0.0. (the working one is the lower version number). Searching for a solution to this led me to your package which looked like a much better solution, but as I have found out only works without expo :(. Expo solution at the moment is to use their 'expo-random' package, but I have tried that and have already got clashes with lists of around 200 so its not really a solution..... |
p.s. I see you have a keen interest in space. Same here! Not sure if this is the right place but I make and mix a lot of 'space-inspired' music. Have a listen here if you like: |
This is the relevant issue for Expo: expo/expo#7209 Please give your thumbs up so that the developers of Expo understand that this is a much desired feature, I've offered to do all the work and submit a PR with the implementation!
Unfortunately, the |
I can add special version of |
same on Expo 36 |
So frustrating. Was excited to have a synchronous solution until my Expo app complete broke after the upgrade to 3.0. 😕 |
I will try to find time at weekend to make |
I added I will release it if somebody will test that it works: npm uninstall nanoid
npm install nanoid@ai/nanoid |
Hi @ai Should I change my imports. - import nanoid from 'nanoid/async'
+ import { nanoid } from 'nanoid' and expect to use synchronous calls? - import nanoid from 'nanoid/async'
+ import { nanoid } from 'nanoid/async' and continue to use async? Thanks! |
@GollyJer you should use async version (but use named export) with expo: - import nanoid from 'nanoid/async'
+ import { nanoid } from 'nanoid/async' |
Cool. That was my guess but wanted to be sure. I will be able to test in app by Thursday at the latest. Thanks. |
Great. I will try to release new version on this weekend. |
Thanks a lot. But I still need install package via And for the change in error message - I didn't mean to change existed (may be mention about |
Nope. You can use
Unfortunately, I do not knwo how to import this error message. ES imports (we support them by |
I can't. That is srange but
I offer forget about it for a while. As I wrote anyone can figure out that he need |
What exactly do you see with |
Nothing. In literal sense. No errors just only first console.log in code beneath, second disappear like in black hole:
|
@1ike show the result of: async addJob(name, args, options) {
console.log('id!');
const promise = uuid();
console.log('promise = ', promise); |
First console.log at 4th line.
Look like With
|
I followed the instructions for 3.1.8 and Expo but get this error. [Unhandled promise rejection: ReferenceError: Can't find variable: crypto]
- node_modules\nanoid\async\index.browser.js:44:2 in nanoid Using expo 37. |
@GollyJer can you try What builder do you use? The default Metro? |
@1ike can you show me the result of: import { getRandomBytesAsync } from 'expo-random'
console.log(getRandomBytesAsync)
console.log(getRandomBytesAsync(5))
getRandomBytesAsync(5).then(bytes => console.log(bytes)) |
There's export at this location.
Yes. The default Metro. |
|
@ai with 3.1.9:
|
Do you use the latest Metro bundler. This error reminds me old Metro problems with dual ESM/CJS packages. |
I updated Expo to 37, but nothing principally changed.
|
Did you have problem with resolving |
Sorry couple latest times I forgot switch to async. So now non-secure also is not working. With
|
🙄 It is very strange. I didn’t change anything in the Are we sure, that builder and environment work correctly? Can I ask you to debug the system to find why |
It wasn't as strange as it was stupid - I forgot to install nanoid after removing. So |
@1ike will |
I mean that Metro continues to ignore Can you try to add this lines to Metro config? resolver: {
resolverMainFields: ['react-native', 'browser', 'main']
} and try normal import |
It did not help. Cause this error. |
Sorry I don't know much about it (neither Expo or Metro). |
I added a full path notice to the docs b0fdb3e and migration guide. Seems like we need to debug Metro builder and how Expo affects its config. I will need help from the Expo developer. |
BTW If import like |
@1ike thanks, I update code example https://github.com/ai/nanoid#react-native |
@ai Looks like sync version support is added to expo |
Can somebody send PR since I have no tools to test it? |
We still have to wait for Expo SDK 39 to ultimately be released in order to test all of this on actual devices. |
@ai facing this issue as well, it says that there's no ts support for index.native but i believe that nanoid/async/index.d.ts will suffice |
As stated in the title, recently installed it into an Expo 37 app as I was all of a sudden getting errors using uuid.V4. Followed the instructions and made sure I installed and imported 'react-native-get-random-values' (both at the top of my index.js entry point of the app, and every where else I used nanoid.
On starting the app I get this error:
I am implementing in my code like this:
Any idea what might be causing this?
The text was updated successfully, but these errors were encountered: