Skip to content

Example NativeEventEmitter.js error (this._nativeModule.addListener is not a function) #232

@mdloucks

Description

@mdloucks

After cloning the repo and running the example/ code, I was greeted with the following error. This looks like an issue in the EventEmmiter library. This happens after following the README.md to set up the example project for the first time.

The app throws this error immediately when it starts up. I believe the library in question is being used by SpotifyRemote.ts. Everything was installed using yarn. I tried changing the react native version to no avail. This is being run on a physical iPhone device using Xcode on M2.

Error


[Thu Feb 16 2023 17:24:40.607] ERROR TypeError: this._nativeModule.addListener is not a function. (In 'this._nativeModule.addListener(eventType)', 'this._nativeModule.addListener' is undefined)

This error is located at:
in AppContextProvider (at App.tsx:50)
in App (at renderApplication.js:45)
in RCTView (at View.js:34)
in View (at AppContainer.js:106)
in RCTView (at View.js:34)
in View (at AppContainer.js:132)
in AppContainer (at renderApplication.js:39)

[Thu Feb 16 2023 17:37:20.100] BUNDLE ./index.js


All code is default from master except for a couple changes

Podfile Includes (Fix for this issue)

pod 'RNSpotifyRemote', :path => '../node_modules/react-native-spotify-remote'
pod 'RNEventEmitter', :path => "../node_modules/react-native-events"

Package.json dependencies

"peerDependencies": {
    "react-native": "0.60"
},
"dependencies": {
    "react-native-spotify-remote": "1.0.0-1"
},
"devDependencies": {
    "@release-it/keep-a-changelog": "^2.2.2",
    "@types/react-native": "0.60.0",
    "all-contributors-cli": "^6.14.2",
    "concurrently": "^5.0.2",
    "release-it": "^14.6.1",
    "typedoc": "^0.20.24",
    "typescript": "^4.1.3"
},

platform :ios, '10.0'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions