{"record":{"id":"dfecc947ee5c7935","repo":"parcel-bundler/parcel","slug":"can-t-find-elm-binary","errorCode":null,"errorMessage":"Can't find 'elm' binary.","messagePattern":"Can't find 'elm' binary\\.","errorType":"exception","errorClass":"ThrowableDiagnostic","httpStatus":null,"severity":"error","filePath":"packages/transformers/elm/src/loadConfig.js","lineNumber":32,"sourceCode":"      diagnostic: {\n        origin: '@parcel/elm-transformer',\n        message: \"The 'elm.json' file is missing.\",\n        hints: [\n          \"Initialize your elm project by running 'elm init'\",\n          \"If you installed elm as project dependency then run 'yarn elm init' or 'npx elm init'\",\n        ],\n      },\n    });\n  }\n\n  return null;\n}\n\nfunction elmBinaryPath(): ?string {\n  let elmBinary = resolveLocalElmBinary();\n\n  if (elmBinary == null && !commandExists.sync('elm')) {\n    throw new ThrowableDiagnostic({\n      diagnostic: {\n        message: \"Can't find 'elm' binary.\",\n        hints: [\n          \"You can add it as an dependency for your project by running 'yarn add -D elm' or 'npm add -D elm'\",\n          'If you want to install it globally then follow instructions on https://elm-lang.org/',\n        ],\n        origin: '@parcel/elm-transformer',\n      },\n    });\n  }\n\n  return elmBinary;\n}\n\nfunction resolveLocalElmBinary() {\n  try {\n    let result = require.resolve('elm/package.json');\n    // $FlowFixMe","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/transformers/elm/src/loadConfig.js#L14-L50","documentation":"Thrown by elmBinaryPath() when neither a local `elm` package (resolved via require.resolve('elm/package.json')) nor a global `elm` on PATH is found. The check runs both when elm.json is missing (to give a combined hint) and when the binary is actually needed for compilation. Diagnostic lists install instructions.","triggerScenarios":"Any Elm transform that needs to invoke the compiler: resolveLocalElmBinary() returns null (no local `elm` npm package) AND commandExists.sync('elm') returns false.","commonSituations":"Fresh clone of an Elm project whose elm dependency was not installed (`npm ci` skipped optional deps); CI image without global elm and no local dependency; switching node_modules between yarn/pnpm where `elm` is not hoisted; the user only installed elm globally but PATH in the build env differs.","solutions":["Add elm as a dev dependency: `npm install -D elm` or `yarn add -D elm` (preferred — reproducible across machines).","If you prefer global install, ensure `elm` is on PATH in the build environment (`which elm` from the same shell).","Re-run `npm ci` / `yarn install --force` if the elm package was partially installed.","For pnpm, ensure elm is resolvable from the workspace that owns the Elm files."],"exampleFix":"# before: only global elm, missing in CI\n# after\nnpm install -D elm","handlingStrategy":"validation","validationCode":"const commandExists = require('command-exists');\nfunction assertElmAvailable() {\n  try { require.resolve('elm/package.json'); return; } catch {}\n  if (!commandExists.sync('elm')) {\n    throw new Error('elm binary missing — run `npm i -D elm`');\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always install elm as a dev dependency rather than relying on a global install.","Pin the elm version in package.json so CI matches local."],"tags":["elm","binary","dependency","environment"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}