clipboard: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNCClipboard' could not be found.
Environment
Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNCClipboard' could not be found. Verify that a module by this name is registered in the native binary.Bridgeless mode: false. TurboModule interop: false. Modules loaded: {"NativeModules":["PlatformConstants","LogBox","Timing","AppState","SourceCode","BlobModule","WebSocketModule","SettingsManager","DevSettings","RedBox","Networking","Appearance","DevLoadingView","UIManager","DeviceInfo","ImageLoader","LinkingManager"],"TurboModules":[],"NotFound":["NativePerformanceCxx","NativePerformanceObserverCxx","BugReporting","HeadlessJsTaskSupport","SoundManager","IntentAndroid","RNCClipboard"]}, js engine: hermes
Platforms
iOS only
Versions
- iOS: 17.2
- react-native: “0.74.1”
- react: “18.2.0” “@react-native-clipboard/clipboard”: “^1.14.1”,
Description
I have the following error Invariant Violation: TurboModuleRegistry.getEnforcing(…): ‘RNCClipboard’ could not be found. Verify that a module by this name is registered in the native binary.Bridgeless mode: false. TurboModule interop: false. Modules loaded: {“NativeModules”:[“PlatformConstants”,“LogBox”,“Timing”,“AppState”,“SourceCode”,“BlobModule”,“WebSocketModule”,“SettingsManager”,“DevSettings”,“RedBox”,“Networking”,“Appearance”,“DevLoadingView”,“UIManager”,“DeviceInfo”,“ImageLoader”,“LinkingManager”],“TurboModules”:[],“NotFound”:[“NativePerformanceCxx”,“NativePerformanceObserverCxx”,“BugReporting”,“HeadlessJsTaskSupport”,“SoundManager”,“IntentAndroid”,“RNCClipboard”]}, js engine: hermes
Reproducible Demo
the error happens when running yarn ios and the application is installed. before even starting the metro bundle it gives an error
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 11
- Comments: 20
So, I had the same problem recently while running my tests after upgrading RN to version 0.74.2. After some research, I found a recommendation for how to mock
@react-native-clipboard/clipboard. Here’s what I did:import mockClipboard from '@react-native-clipboard/clipboard/jest/clipboard-mock.js';jest.mock('@react-native-clipboard/clipboard', () => mockClipboard);After this, the issue was resolved.
Having the same issue
In my case, I encountered the same issue and was able to resolve it with the following steps:
I changed the import from:
to:
For copying a string to the clipboard:
It worked for me on Android devices. I hope this helps anyone facing the same issue!
Here’s another way to mock
@react-native-clipboard/clipboard, I solved the issue in this way.__mocks__/@react-native-clipboarddirectory.export * from '@react-native-clipboard/clipboard/jest/clipboard-mock.js';@nishith003 I tried your fix, but it didn’t work for me.
I experienced it on mocha tests after version upgrade and I mocked the module. Does it affect production code?
Facing same issue in iOS
"@react-native-clipboard/clipboard": "^1.16.0","react-native": "0.77.0-rc.6",Rebuilding the app fixed it for me
@suhmah I really don’t get why this is happening, but using
expo moduleswithexpo dev clientand expo-clipboard package solved the whole problem to me.I want to just add the the newer version of Expo requires minimum development target to be 13.4 on iOS environments.