Skip to content
Latchkey

GitHub Actions "Cannot find module" - JavaScript Action main Not Found

A JavaScript action fails to start because the file named by runs.main does not exist on disk. The action.yml points at a bundle that was never built or never committed.

What this error means

The step fails immediately with "Cannot find module" naming the path in runs.main (often dist/index.js). No action logic runs because Node has nothing to execute.

Actions log
Error: Cannot find module '/home/runner/work/_actions/my-org/my-action/v1/dist/index.js'
Require stack: ...

Common causes

The bundle was never built or committed

JavaScript actions run the committed file, not your TypeScript source. If dist/ is gitignored or you forgot to run the bundler before tagging, the referenced file is absent.

runs.main points at the wrong path

action.yml declares runs.using: node20 and runs.main: <file>. A typo or a path relative to the wrong directory makes the runner look where nothing exists.

How to fix it

Build and commit the bundle, then point main at it

Bundle the action to a single file with ncc and commit that file so the tagged ref contains it.

Terminal
npx @vercel/ncc build src/index.ts -o dist
git add -f dist/index.js   # ensure dist is not gitignored

Match runs.main to the committed file

action.yml
runs:
  using: node20
  main: dist/index.js

How to prevent it

  • Run the bundler in CI and fail if dist/ is dirty, so an unbuilt action never tags.
  • Do not gitignore the action dist/ directory.
  • Pin consumers to a tag/SHA that you have verified contains the built bundle.

Related guides

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