Skip to content
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

[bug]: import_http.default.Agent is not a constructor on expo project #1582

Open
LamsaLL opened this issue Mar 4, 2025 · 4 comments
Open
Labels

Comments

@LamsaLL
Copy link

LamsaLL commented Mar 4, 2025

Description

I get the following error on web when importing algoliasearch client :

Image

Client

Search

Environment

  expo-env-info 1.2.2 environment info:
    System:
      OS: Linux 5.4 Ubuntu 20.04.6 LTS (Focal Fossa)
      Shell: 5.8 - /usr/bin/zsh
    Binaries:
      Node: 21.1.0 - /usr/local/bin/node
      Yarn: 1.22.19 - /usr/local/bin/yarn
      npm: 10.3.0 - /usr/local/bin/npm
    SDKs:
      Android SDK:
        API Levels: 29, 30, 31, 32, 33, 34
        Build Tools: 29.0.2, 30.0.3, 31.0.0, 33.0.0, 33.0.1, 34.0.0, 35.0.0
        System Images: android-30 | Google APIs Intel x86 Atom, android-30 | Google APIs Intel x86 Atom_64, android-30 | Google Play Intel x86 Atom
    npmPackages:
      expo: ~52.0.37 => 52.0.37 
      expo-router: ~4.0.17 => 4.0.17 
      react: 18.3.1 => 18.3.1 
      react-dom: 18.3.1 => 18.3.1 
      react-native: 0.76.7 => 0.76.7 
      react-native-web: ^0.19.13 => 0.19.13 
    npmGlobalPackages:
      eas-cli: 7.2.0
      expo-cli: 6.3.10
    Expo Workflow: managed

Minimal reproducible example : https://github.com/LamsaLL/test-algolia

@LamsaLL LamsaLL added the bug label Mar 4, 2025
@Haroenv
Copy link
Contributor

Haroenv commented Mar 4, 2025

Not sure of the cause for resolving to the node version on expo, but you can make sure to use the fetch (@algolia/requester-fetch) or the xhr requester (@algolia/requester-browser-xhr)

@shortcuts
Copy link
Member

I think metro resolves to the react-native field (https://github.com/algolia/algoliasearch-client-javascript/blob/main/packages/algoliasearch/package.json#L65) but you might be able to better configure it with https://metrobundler.dev/docs/package-exports/

@LamsaLL
Copy link
Author

LamsaLL commented Mar 4, 2025

@Haroenv I tried using requester-fetch and requester-browser-xhr :

import { createFetchRequester } from "@algolia/requester-fetch";

const searchClient = algoliasearch("undefined", "undefined", {
  requester: createFetchRequester(),
});

But i get same error. @shortcuts I don't really understand what i need to configure on metro.

@LamsaLL
Copy link
Author

LamsaLL commented Mar 4, 2025

I tried using algoliasearch with expo 51.0.39, and it worked well. It seems to be broken only on expo 52.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants