Skip to content

Unable to resolve "@socket.io/component-emitter" #1598

@jpgorman

Description

@jpgorman

Describe the bug
Using socket.io-client in react native causes a build error

Web Bundling failed 5906ms
Unable to resolve "@socket.io/component-emitter" from "node_modules/socket.io-client/build/esm/manager.js"

To Reproduce

Please fill the following code example:

Socket.io-client version: ^4.7.2

Client

import io from "socket.io-client"; 
...

Expected behavior
To resolve Socket.io-client library modules

Platform:

  • React Native: 0.72.6
  • Metro bundler: 0.76.8
  • Expo: ~49.0.15
  • OS: [e.g. Mac OS 9.2]

Additional context
I did find a work around via the metro bundler config using the following

  const { getDefaultConfig } = require('expo/metro-config');
   /** @type {import('expo/metro-config').MetroConfig} */
   const config = getDefaultConfig(__dirname, {
    ...
   });
   
   
   module.exports = (async () => {
    // add support to implicitly resolve modules with .(c|m)js extensions
    config.resolver.sourceExts.push('cjs');
    config.resolver.sourceExts.push('mjs');
    return config;
   })();

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions