Skip to content
Latchkey

ReScript "Module X not found" in CI

The ReScript compiler reached a module reference it cannot resolve. The dependency is missing from the bs-dependencies in rescript.json (or bsconfig.json), or the npm package was never installed.

What this error means

rescript build fails with "The module or file X can't be found." and lists where it looked, often suggesting the dependency is not declared.

ReScript
  We've found a bug for you!
  /src/App.res:2:8-19

  The module or file Belt_Array can't be found.
  - Did you add it to the bs-dependencies in rescript.json?

Common causes

The dependency is not in rescript.json

A package providing the module is installed in node_modules but not listed in bs-dependencies, so the compiler does not include it.

The npm package is not installed

The dependency is referenced but npm install never ran or did not fetch it, so the module source is absent.

How to fix it

Add the dependency to rescript.json

  1. Install the npm package that provides the module.
  2. Add it to bs-dependencies in rescript.json.
  3. Re-run rescript build.
rescript.json
{
  "bs-dependencies": ["@rescript/core"]
}

Install dependencies before building

Ensure npm ci runs before rescript build so every declared dependency is present in node_modules.

Terminal
npm ci
npx rescript build

How to prevent it

  • Keep bs-dependencies in sync with the packages your code imports.
  • Run npm ci before rescript build in CI.
  • Use a clean build (rescript clean) when switching dependency versions.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →