## TL;DR

Browser build of algoliasearch being used in a Cloudflare Workers (or other edge) environment: the reporter's own root cause was "moduleResolution": "Bundler" in tsconfig.json resolving the wrong build. Changing moduleResolution fixed it on their end.

## Steps

1. Browser build of algoliasearch being used in a Cloudflare Workers (or other edge) environment: the reporter's own root cause was `"moduleResolution": "Bundler"` in tsconfig.json resolving the wrong build. Changing moduleResolution fixed it on their end. If you hit XMLHttpRequest-is-not-defined style errors in a non-browser runtime, check your tsconfig moduleResolution first.

2. _Source: https://github.com/algolia/algoliasearch-client-javascript/issues/1548 (Algolia)_

## When to use

You are seeing this: If you hit XMLHttpRequest-is-not-defined style errors in a non-browser runtime, check your tsconfig moduleResolution first. _Source: https://github.com/algolia/algoliasearch-client-javascript/issues/1548 (Algolia)_ Use this skill when you run into "Browser build is used in CF workers environment".

## 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

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

## 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/algolia/algoliasearch-client-javascript/issues/1548
