Skip to content

[Bug]: ejslint fails to spawn in pre-commit hook when modifying .ejs files #33433

@ia319

Description

@ia319

Describe the bug

When committing changes to .ejs files in the code/ directory, the pre-commit hook fails with ENOENT error.

husky > pre-commit (node v22.21.1)
✔ Backed up original state in git stash (b5858fbb44c)
⚠ Running tasks for staged files...
  ❯ package.json — 1 file
    ↓ *.{html,js,json,jsx,mjs,ts,tsx} — no files
    ❯ *.ejs — 1 file
      ✖ ../scripts/node_modules/.bin/ejslint [FAILED]
    ↓ *.{css,html,json,md,yml} — no files
    ↓ package.json — no files
↓ Skipped because of errors from tasks.
✔ Reverting to original state because of errors...
✔ Cleaning up temporary files...

✖ ../scripts/node_modules/.bin/ejslint failed to spawn:
Command failed: ../scripts/node_modules/.bin/ejslint <repo>/code/core/assets/server/template.ejs
Error: spawn ../scripts/node_modules/.bin/ejslint ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn ../scripts/node_modules/.bin/ejslint',
  path: '../scripts/node_modules/.bin/ejslint',
  spawnargs: [
    '<repo>/code/core/assets/server/template.ejs'
  ]
}
husky > pre-commit hook failed (add --no-verify to bypass)

Reproduction link

...

Reproduction steps

  1. Modify any .ejs file (e.g., code/core/assets/server/template.ejs)
  2. Run git add . && git commit -m "test"

System

OS: Linux (WSL)
Node.js: v22.21.1
Yarn: v4.10.3 (via corepack)
corepack: enabled and active
yarn binary: ~/.nvm/versions/node/v22.21.1/bin/yarn

Additional context

This repository uses nodeLinker: node-modules in .yarnrc.yml.
According to the Yarn Berry documentation,

  • nmHoistingLimits is not set, so it defaults to none.
  • With nmHoistingLimits: none, Yarn hoists packages as much as possible to the project root node_modules.
  • Therefore, ejs-lint declared in scripts/package.json is hoisted to node_modules/.bin/ejslint at the project root instead of staying under scripts/node_modules/.bin/ejslint.
/storybook/scripts$ ls node_modules/.bin/ejslint
ls: cannot access 'node_modules/.bin/ejslint': No such file or directory

/storybook/scripts$ cd ..
/storybook$ ls node_modules/.bin/ejslint
node_modules/.bin/ejslint```

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions