parcel-bundler/parcel · error · ThrowableDiagnostic

The 'elm.json' file is missing.

Error message

The 'elm.json' file is missing.

What it means

Thrown by @parcel/transformer-elm's config loader when config.getConfig(['elm.json']) returns nothing. Before throwing, it calls elmBinaryPath() so a missing-binary hint can also surface. The diagnostic is a ThrowableDiagnostic with hints pointing to `elm init`.

Source

Thrown at packages/transformers/elm/src/loadConfig.js:13

// @flow strict-local

import type {Config} from '@parcel/types';
import path from 'path';
import ThrowableDiagnostic from '@parcel/diagnostic';
import commandExists from 'command-exists';
import nullthrows from 'nullthrows';

async function load({config}: {|config: Config|}): Promise<null> {
  const elmConfig = await config.getConfig(['elm.json']);
  if (!elmConfig) {
    elmBinaryPath(); // Check if elm is even installed
    throw new ThrowableDiagnostic({
      diagnostic: {
        origin: '@parcel/elm-transformer',
        message: "The 'elm.json' file is missing.",
        hints: [
          "Initialize your elm project by running 'elm init'",
          "If you installed elm as project dependency then run 'yarn elm init' or 'npx elm init'",
        ],
      },
    });
  }

  return null;
}

function elmBinaryPath(): ?string {
  let elmBinary = resolveLocalElmBinary();

  if (elmBinary == null && !commandExists.sync('elm')) {

View on GitHub (pinned to 59484858a1)

Solutions

  1. Run `elm init` (or `npx elm init` / `yarn elm init`) in the same directory as elm.json should live (Parcel's projectRoot).
  2. If elm.json exists elsewhere, run Parcel from the directory containing it or restructure so it sits at the project root.
  3. Make sure elm.json is committed (not gitignored) in shared projects.
  4. If Elm is not actually used, remove the stray .elm file or exclude it.

Example fix

# before: project root has src/Main.elm but no elm.json
elm init   # creates elm.json with src/ in source-directories
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs');
const path = require('path');
function assertElmJson(projectRoot) {
  if (!fs.existsSync(path.join(projectRoot, 'elm.json'))) {
    throw new Error('elm.json missing — run `elm init` before building');
  }
}

Prevention

When it happens

Trigger: An Elm source file (a .elm asset) is being transformed but the project root has no elm.json. Parcel only triggers the Elm transformer when an Elm file is in the dependency graph.

Common situations: Adding an .elm file without running `elm init`; cloning an Elm project whose elm.json is gitignored; building from the wrong directory so Parcel's projectRoot does not contain elm.json.

Related errors


AI-assisted analysis of parcel-bundler/parcel@59484858a1 (2026-08-13). Data as JSON: /api/errors/7bfa4a73504cf87f. Report an issue: GitHub.