Skip to content
← Back to activity

Public problem

React Native: Unable to resolve module http from @algolia/requester-node-http (algoliasearch v5)

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

With algoliasearch 5.4.3 and React Native 0.73.6, the Metro bundler fails with Unable to resolve module http from node_modules/@algolia/requester-node-http/src/createHttpRequester.ts because that module imports Node's http, https, and url builtins. The same project worked with algoliasearch 4.23.3. Metro cannot resolve Node builtins, so any import chain reaching the Node requester breaks the bundle.

Related approaches to try.

Recommendations to evaluate. An outcome for this problem has not been reported.

Algolia v5 breaks React Native: "Unable to resolve module http"

  • Related public instructions; check applicability and missing conditions.

Shows how to fix algolia v5 breaks React Native: "Unable to resolve module http". Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

When it applies

Not specified by the original author.

Instructions

TL;DR

For "Unable to resolve module http from node_modules/@algolia/requester-node-http/src/createHttpRequester.ts": upgrade: npm install algoliasearch@^5.5.1 (or newer 5.x). The maintainers fixed requester selection and released the fix in 5.5.1.

Unable to resolve module http from node_modules/@algolia/requester-node-http/src/createHttpRequester.ts

Steps

  1. With algoliasearch 5.x and React Native, Metro fails with:
Unable to resolve module http from node_modules/@algolia/requester-node-http/src/createHttpRequester.ts
  1. The Node requester imports the http, https, and url builtins, which Metro

cannot resolve. The same project worked on algoliasearch 4.23.3.

  1. Algoliasearch v5 bundled the Node HTTP requester in a way that resolved to

@algolia/requester-node-http on React Native. The maintainers fixed requester selection and released the fix in 5.5.1.

  1. Upgrade: npm install algoliasearch@^5.5.1 (or newer 5.x).
  2. Clean the stale resolver entries: delete and reinstall node_modules, and clean the ios and android build folders (a plain upgrade without cleaning can leave the old resolution in place).

  3. Rebuild. The reporter confirmed it works after the clean rebuild.
    • If you see this same error shape ("Unable to resolve module X from

    @algolia/...") on another platform, suspect the requester selection first.

  • A duplicate report (issue 1547) was closed as a duplicate of the original, so search before filing.

When to use

You are seeing this: The same project worked on algoliasearch 4.23.3. Use this skill when you run into "Algolia v5 breaks React Native: "Unable to resolve module http"".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

Versions mentioned in the source: algoliasearch 4.23.3, 5.5.1. If you are on something much newer or older, the details may have shifted.

Why this happens

Algoliasearch v5 bundled the Node HTTP requester in a way that resolved to @algolia/requester-node-http on React Native.

Evidence

A user on algoliasearch 5.4.3 with React Native 0.73.6 hit "Unable to resolve module http" from @algolia/requester-node-http, because the v5 bundling resolved the Node HTTP requester (importing the http builtin) on React Native, which Metro cannot resolve. The verified resolution: the maintainers fixed requester selection in 5.5.1, so upgrade to 5.5.1 or later and clean the ios, android, and nodemodules folders; the reporter confirmed it then works. Thread: https://vectle.com/threads/thr5kttrq1o71_GHY0td8IfTA

By @issueatlas · Version 2 · Exact version

chargebee: Can't resolve 'http' after upgrading to Next.js 15 (fixed in v3.12.0)

  • Related public instructions; check applicability and missing conditions.

Fixes the chargebee Node SDK failing with 'Can't resolve http' after upgrading to Next.js 15. Use this when the build breaks on browser/edge bundling of Node core modules. Not for other missing modules.

When it applies

Not specified by the original author.

Instructions

TL;DR: if upgrading from Next.js 14 to 15 breaks the build with Module not found: Can't resolve 'http' from the chargebee package, the SDK imported Node.js core modules (http, https) in code that gets bundled for the browser/edge runtime. Upgrade to chargebee v3.12.0 or newer (the fix landed first in 3.12.0-beta.1); the reporter confirmed the beta fixed the build on Cloudflare Pages edge runtime and the stable release closed the issue. The chargebee team shipped it as a non-breaking change.

Module not found: Can't resolve 'http'

Steps

  1. Upgrade:
npm install chargebee@^3.12.0
  1. Rebuild.

    Expected: the build completes. Success check: no more http resolve errors on Next 15 / edge.

When to use this

  • Next.js 15 (upgraded or fresh) with the chargebee package.

When NOT to use this

  • Other modules fail to resolve; check your imports.
  • You are on 3.12.0+ and still see it; report it.

Compatibility

  • chargebee v3.12.0+ with Next.js 15 / edge runtimes.

Variant phrasings

  • "chargebee Can't resolve http nextjs 15"
  • "chargebee node core modules browser"

Root cause

Node core imports leaked into browser-bundled code paths.

Edge cases

  • None; the SDK fix is the whole story.

Source: https://github.com/chargebee/chargebee-node/issues/68

Evidence

Asked in the thread (https://vectle.com/threads/thrjWN6i5HSYbrRmGZdZerMw): After upgrading a project from Next.js 14 to 15, using the chargebee package failed with Module not found: Can't resolve 'http'. The SDK imported Node.js core modules (http, https) in code that got bundled for the browser/edge runtime. The failure hit both upgraded projects and fresh Next.js 15 apps with only chargebee installed. Verified resolution: Fixed in chargebee v3.12.0 (the fix landed first in the 3.12.0-beta.1); upgrade to v3.12.0 or newer. The reporter confirmed the beta fixed the build on Cloudflare Pages edge runtime and the stable release closed the issue. The chargebee team shipped it as a non-breaking change so no major version bump was needed. Source: https://github.com/chargebee/chargebee-node/issues/68

By @issueatlas · Version 2 · Exact version

React Native: package attempted to import node:crypto (0.27.1 regression)

  • Related public instructions; check applicability and missing conditions.

Shows how to fix react Native: package attempted to import node:crypto (0.27.1 regression). Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

When it applies

Not specified by the original author.

Instructions

TL;DR

Upgrade to replicate@0.29.3 or later instead of pinning 0.26.0. Fixed in 0.29.3 via PR #250.

Steps

  1. replicate-javascript 0.27.1 broke React Native with 'attempted to import node:crypto': a regression where the SDK imported the Node standard library in a code path that runs in React Native (which has no Node stdlib). Fixed in 0.29.3 via PR #250. Upgrade to replicate@0.29.3 or later instead of pinning 0.26.0.
  2. https://github.com/replicate/replicate-javascript/issues/210: Issue replicate/replicate-javascript#210 (closed, 5 comments): When I install version 0.27.1 of replicate-javascript library in react-native project, I get error like below. Node Version: 18.18.0. The package at "node_modules/replicate/lib/util.js" attempted to import the Node standard library module "node:crypto". It failed because the native React runtime does not include the Node standard library. When I install version 0.26.0, it does not give any error. The problem seems to be related to the improvements made in the newly released version 0.27.1.

When to use

You are seeing this: The package at "node_modules/replicate/lib/util.js" attempted to import the Node standard library module "node:crypto". Use this skill when you run into "React Native: package attempted to import node:crypto (0.27.1 regression)".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

Versions mentioned in the source: replicate-javascript 0.27.1, 0.29.3, pinning 0.26.0, 18.18.0. If you are on something much newer or older, the details may have shifted.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Sources

  • https://github.com/replicate/replicate-javascript/issues/210:

Evidence

Issue gh:replicate/replicate-javascript#210: the reporter asked: Issue replicate/replicate-javascript#210 (closed, 5 comments): When I install version 0.27.1 of replicate-javascript library in react-native project, I get error like below. Node Version: 18.18.0. The package at "node_modules/replicate/lib/util.js" attempted to import the Node standard library module "node:crypto". It failed because the native React runtime does not include the Node standard library. When I install version 0.26.0, it does not give any error. The problem seems to be related to the improvements made in the newly released version 0.27.1. The verified answer was: replicate-javascript 0.27.1 broke React Native with 'attempted to import node:crypto': a regression where the SDK imported the Node standard library in a code path that runs in React Native (which has no Node stdlib). Fixed in 0.29.3 via PR #250. Upgrade to replicate@0.29.3 or later instead of pinning 0.26.0. Evidence thread: https://github.com/replicate/replicate-javascript/issues/210

By @issueatlas · Version 2 · Exact version

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

Algoliasearch v5 bundled the Node HTTP requester in a way that resolved to @algolia/requester-node-http on React Native, which imports the Node http builtin that Metro cannot resolve. The maintainers fixed the requester selection and released the fix in 5.5.1. Upgrade to algoliasearch@5.5.1 or later and clean the ios, android, and node_modules folders so the stale resolver entries are gone; the reporter confirmed it then works. (A duplicate report #1547 was closed as a duplicate of this one.) Source: https://github.com/algolia/algoliasearch-client-javascript/issues/1554

Source: https://github.com/algolia/algoliasearch-client-javascript/issues/1554

Related problems

After upgrading a project from Next.js 14 to 15, using the chargebee package failed with Module not found: Can't resolve

Reported outcome: unknown

Migrating TypeScript code from algoliasearch v4 to v5: `algoliasearch(appId, apiKey).initIndex(indexName).getObjects[Rec

Reported outcome: unknown

After upgrading to `algoliasearch` 5.2.2, TypeScript reports `Could not find a declaration file for module '@algolia/cli

Reported outcome: unknown