"Error: Native module not found" error when using uuidv4 in React Native app (non Expo)

See original GitHub issue

Describe the bug

When I try to use uuidv4 in my vanilla react native (non-Expo) app, I’m getting “Error: Native module not found” error. I’m importing the two needed dependencies correctly as far as I can tell, and the same way worked for my Expo app:

import 'react-native-get-random-values';
import {v4 as uuidv4} from 'uuid';
...
// some where in my render() function
const myID = uuidv4(); // throws error

I’ve verified /node_modules has the two packages downloaded correctly too.

How to reproduce

Basically what I described above - I’m using basically a blank RN app.

Expected behavior

uuidv4() should work with react-native-get-random-values imported above it.

Runtime

  • OS: macOS
  • Runtime: react-native (non-Expo)
  • Runtime Version: 0.64.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
LinusUcommented, Dec 8, 2021

[…] make react-native-get-random-values a peerDependency of your library and document the necessary steps to install it.

This is what I would recommend as well 👍

I think we can close this one now since a workaround have been found, there doesn’t seem to be anything we can change in uuid, and there hasn’t been any recent activity…

1reaction
ctavancommented, Jun 24, 2021

I think the fact that a manual npx pod-install is currently necessary in order to install react-native-get-random-values is something that cannot be fixed in uuid but would have to be approached in https://github.com/LinusU/react-native-get-random-values, so feel free to raise an issue over there.

Until then I think the best bet is to make react-native-get-random-values a peerDependency of your library and document the necessary steps to install it.

Maybe one more idea: Have you tried adding react-native-get-random-values as a dependency to your library and the necessary manual install steps in a postinstall hook?

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Error: Native module not found" error when using uuidv4 in React ...
Describe the bug. When I try to use uuidv4 in my vanilla react native (non-Expo) app, I'm getting "Error: Native module not found"...
Read more >
Can't resolve 'uuid/v4' in react-native - Stack Overflow
Failed to compile. Module not found: Can't resolve 'uuid/v4' in 'F:\App 2nd\chat2\SecreteChat\node_modules\expo-constants ...
Read more >
[Solved]-Can't resolve 'uuid/v4' in react-native-React Native
How to resolve React Native iOS linking error:: 'ReactNativeNavigation/ReactNativeNavigation.h' file not found? React Native importing error: unable to resolve ...
Read more >
Issue with UUIDv4 : r/reactnative - Reddit
Hey there, new to React Native (working in expo) and running into an issue. Trying to follow Brad Traversy's React Native Crash Course...
Read more >
uuid - NPM Package Overview - Socket.dev
Start using Socket to analyze uuid and its 0 dependencies to secure your app ... Webpack and rollup.js module bundlers; React Native /...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found