react-native-deprecated-modules icon indicating copy to clipboard operation
react-native-deprecated-modules copied to clipboard

Invariant Violation: `new NativeEventEmitter()` requires a non-null argument

Open Etaliya opened this issue 3 years ago • 7 comments

After I add this modal I started to get the error Invariant Violation: new NativeEventEmitter() requires a non-null argument

simulator_screenshot_3D7ABA4D-4203-426D-B424-F82257F5E8B3

info Fetching system and libraries information... System: OS: macOS 12.5 CPU: (6) x64 Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz Memory: 1.75 GB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.19.0 - ~/.nvm/versions/node/v16.19.0/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 8.19.3 - ~/.nvm/versions/node/v16.19.0/bin/npm Watchman: 2022.12.26.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1 Android SDK: Not Found IDEs: Android Studio: 2021.3 AI-213.7172.25.2113.9123335 Xcode: 14.2/14C18 - /usr/bin/xcodebuild Languages: Java: 11.0.17 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.1.0 => 18.1.0 react-native: 0.70.6 => 0.70.6 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Etaliya avatar Jan 02 '23 08:01 Etaliya

@Etaliya it's really hard to understand what's going on, since you are not providing any type of information about your system nor repro steps.

Can you run npx react-native info and paste the content in a comment there? Also, can you add clear, reproducible steps so that a person not using your project can verify the error?

kelset avatar Jan 03 '23 11:01 kelset

Which platform are you targeting? From the error, it looks like that the NativeEventEmitter has been initialized with null. If we crawl the stacktrace, the referred file is PushNotificationIOS.js. Here, it specify that it will return null as NativeEventEmitter parameter only if the platform is not iOS.

Could you provide a repro for this error?

cipolleschi avatar Jan 03 '23 11:01 cipolleschi

@kelset I just integrate this dependency and set module-resolver in babel.config.js file and the run project and got this error.

var path = require('path');

module.exports = { presets: ['module:metro-react-native-babel-preset'], plugins: [ ['@babel/plugin-proposal-decorators', {legacy: true}], [ 'module-resolver', { root: ['.'], resolvePath(sourcePath, currentFile) { if ( sourcePath === 'react-native' && !( ( currentFile.includes('node_modules/react-native/') || // macos/linux paths currentFile.includes('node_modules\react-native\') ) // windows path ) && !( currentFile.includes('resolver/react-native/') || currentFile.includes('resolver\react-native\') ) ) { return path.resolve(__dirname, 'resolver/react-native'); } return undefined; }, }, ], ], };

Etaliya avatar Jan 04 '23 05:01 Etaliya

Can you run npx react-native info and paste the content in a comment there?

Also, why would you manually add this dependency in your project?

kelset avatar Jan 04 '23 10:01 kelset

@kelset info Fetching system and libraries information... System: OS: macOS 12.5 CPU: (6) x64 Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz Memory: 1.75 GB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.19.0 - ~/.nvm/versions/node/v16.19.0/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 8.19.3 - ~/.nvm/versions/node/v16.19.0/bin/npm Watchman: 2022.12.26.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1 Android SDK: Not Found IDEs: Android Studio: 2021.3 AI-213.7172.25.2113.9123335 Xcode: 14.2/14C18 - /usr/bin/xcodebuild Languages: Java: 11.0.17 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.1.0 => 18.1.0 react-native: 0.70.6 => 0.70.6 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Etaliya avatar Jan 06 '23 05:01 Etaliya

why did you manually add react-native-deprecated-modules in your project? what is the use case?

kelset avatar Jan 06 '23 10:01 kelset

Hey @Etaliya how did you solve it? please help

yashukla47 avatar Feb 18 '23 20:02 yashukla47