-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Unable to require NativeModules from custom debuggerWorker.js #24622
Comments
Thanks for submitting your issue. Can you take another look at your description and make sure the issue template has been filled in its entirety? 👉 Click here if you want to take another look at the Bug Report issue template. |
It looks like you are using an older version of React Native. Please update to the latest release, v0.59 and verify if the issue still exists. The "Resolution: Old Version" label will be removed automatically once you edit your original post with the results of running `react-native info` on a project using the latest release.
|
Hey @SounD120 I'm using the The path to the lib will probably have to be required as |
Hey @Salakar . Thanks a lot for your help. It works for us, that's how we solved this issue: microsoft/vscode-react-native#992 |
@SounD120 you're welcome! Glad it helped 🎉 |
🐛 Bug Report
Hello, I am a maintainer of React Native Tools extension for Visual Studio Code. Extension is developed to provide React Native apps debugging to VS Code. It also provides some other functions to make development easier.
We use a custom debugger that works that way: extension downloads original
debuggerWorker.js
from Metro packager server, then patches it and runs it as a Node.js debug process. You can find the whole customdebuggerWorker.js
that we use by this link.We had added a feature for users so they could open Dev Menu on native app by calling a simple command in VS Code. It worked the following way:
debuggerWorker.js
This trick worked in previous versions on React Native, but, infortunately, in the more recent ones (0.57+) it stopped working due to
NativeModules
package is couldn't be resolved.To Reproduce
react-native init
commandDebug iOS
debug scenario using the instructions from ReadmeRemote JS Debug
React Native: Show Dev Menu
, React Native Dev Menu won’t be shownExpected Behavior
require
function resolvesNativeModules
correctly.Code Example
We tried a different combinations of methods to fix it:
require('NativeModules').DevMenu.show();
require('react-native').NativeModules.DevMenu.show();
global.require('NativeModules').DevMenu.show();
global.require('react-native').NativeModules.DevMenu.show();
All of this approaches have led to error with description
Cannot find module 'NativeModules'
. On version0.59.*
require('react-native')
have led to error with descriptionError: Cannot find module 'warnOnce'
(may be connected to #23943)In case when we required
react-native
package there were no modules that were resolved correctly at all.Example:
Environment
Also, if you have any other suggestions/alternatives of how it could be done, please let us know.
The text was updated successfully, but these errors were encountered: