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.
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.
npx @vercel/ncc build src/index.ts -o dist
git add -f dist/index.js # ensure dist is not gitignoredMatch runs.main to the committed file
runs:
using: node20
main: dist/index.jsHow 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.