clipboard icon indicating copy to clipboard operation
clipboard copied to clipboard

Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNCClipboard' could not be found.

Open suhmah opened this issue 1 year ago • 21 comments

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

image image

Reproducible Demo

the error happens when running yarn ios and the application is installed. before even starting the metro bundle it gives an error

suhmah avatar May 28 '24 06:05 suhmah

Having the same issue

nvacheishvili avatar May 29 '24 15:05 nvacheishvili

Same here. Did the pod install in the ios directory. Still getting the issue.

BrianIto avatar Jun 03 '24 14:06 BrianIto

Same issue in andriod also while testing in real device.

poojagirne avatar Jun 04 '24 12:06 poojagirne

@suhmah I really don't get why this is happening, but using expo modules with expo dev client and 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.

BrianIto avatar Jun 04 '24 12:06 BrianIto

@suhmah I really don't get why this is happening, but using expo modules with expo dev client and 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.

Even after using Expo, I am still getting the same error while testing on an actual device, not in the simulator.

poojagirne avatar Jun 04 '24 12:06 poojagirne

I got same issue.

Nelie-Taylor avatar Jun 11 '24 08:06 Nelie-Taylor

Both Android emulators and devices have the same problem.

ijs1103 avatar Jun 11 '24 11:06 ijs1103

I have the same error.

truezombie avatar Jun 14 '24 11:06 truezombie

I got the error again, and then migrated to expo-clipboard. Sorry, folks, that's not much help but it is what worked for me. :(

BrianIto avatar Jun 14 '24 17:06 BrianIto

I experienced it on mocha tests after version upgrade and I mocked the module. Does it affect production code?

UgurGumushan avatar Jul 02 '24 17:07 UgurGumushan

Rebuilding the app fixed it for me

williamAstudillo avatar Aug 13 '24 17:08 williamAstudillo

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:

  • I imported mockClipboard at the top of the setupJest file: import mockClipboard from '@react-native-clipboard/clipboard/jest/clipboard-mock.js';
  • I Added the following block of code between my mocks: jest.mock('@react-native-clipboard/clipboard', () => mockClipboard);

After this, the issue was resolved.

MarcosCunhaDev avatar Aug 26 '24 19:08 MarcosCunhaDev

In my case, I encountered the same issue and was able to resolve it with the following steps:

I changed the import from:

import Clipboard from '@react-native-clipboard/clipboard';

to:

import * as Clipboard from '@react-native-clipboard/clipboard';

For copying a string to the clipboard:

Clipboard.default.setString(address);

It worked for me on Android devices. I hope this helps anyone facing the same issue!

nishith003 avatar Oct 17 '24 11:10 nishith003

@nishith003 I tried your fix, but it didn't work for me.

JohnSmall avatar Oct 31 '24 09:10 JohnSmall

same issue

dibasdauliya avatar Nov 27 '24 19:11 dibasdauliya

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:

  • I imported mockClipboard at the top of the setupJest file: import mockClipboard from '@react-native-clipboard/clipboard/jest/clipboard-mock.js';
  • I Added the following block of code between my mocks: jest.mock('@react-native-clipboard/clipboard', () => mockClipboard);

After this, the issue was resolved.

Here's another way to mock @react-native-clipboard/clipboard, I solved the issue in this way.

  1. In your project root directory, create __mocks__/@react-native-clipboard directory.
  2. Inside that folder, create clipboard.js file.
  3. Inside that file, export clipboard mock. export * from '@react-native-clipboard/clipboard/jest/clipboard-mock.js';

xiangjiu0918 avatar Nov 30 '24 17:11 xiangjiu0918

Im having the same issue, did anybody found a fix yet?

GustBM avatar Dec 06 '24 15:12 GustBM

Facing same issue in iOS "@react-native-clipboard/clipboard": "^1.16.0", "react-native": "0.77.0-rc.6", simulator_screenshot_B92E4757-486E-43BC-A5A9-79000048038C

fawaz-ahmed avatar Jan 09 '25 12:01 fawaz-ahmed

  • jest.mock('@react-native-clipboard/clipboard', () => mockClipboard);

This worked for me! Thank you!

crosenfrisk avatar Jan 27 '25 23:01 crosenfrisk

Rebuilding/starting the app directly from xCode, rather than Metro, fixed the issue for me

jfries289 avatar Sep 16 '25 00:09 jfries289