Skip to content

fix: Fix check_translations pre-commit hook failures due to corrupted node_modules#326

Open
Copilot wants to merge 3 commits intomainfrom
copilot/fix-translation-files-issue
Open

fix: Fix check_translations pre-commit hook failures due to corrupted node_modules#326
Copilot wants to merge 3 commits intomainfrom
copilot/fix-translation-files-issue

Conversation

Copy link
Contributor

Copilot AI commented Oct 13, 2025

Problem

The check_translations pre-commit hook was failing in CI with the following error:

sh: 1: lit-localize: not found
make: *** [Makefile:95: check_translations] Error 127

The root cause was that when npm install was run multiple times or encountered filesystem errors during installation, it could leave the node_modules directory in a corrupted state. This prevented the lit-localize command from being properly installed and available in the PATH.

The error logs showed numerous TAR_ENTRY_ERROR messages and ENOENT errors during npm installation:

npm warn tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/.../typescript/lib/typescript.js'
npm error code ENOENT
npm error syscall mkdir
npm error path /home/runner/.../node_modules/wrap-ansi-cjs
npm error errno -2

Solution

Modified the check_translations target in the Makefile to:

  1. Remove node_modules before installation using rm -rf node_modules to ensure a clean state
  2. Use npm ci instead of npm install for cleaner, more reproducible installations
- cd frontend && npm install && npm run translations:extract
+ cd frontend && rm -rf node_modules && npm ci && npm run translations:extract

Why npm ci?

  • npm ci is designed for CI/CD environments and automated workflows
  • It removes node_modules automatically and performs a clean installation
  • It's more reliable and faster than npm install for repeated runs
  • It provides better reproducibility by strictly following package-lock.json

Testing

✅ Verified the command works on clean installations
✅ Tested idempotency (multiple consecutive runs succeed)
✅ Simulated corrupted node_modules scenario and confirmed the fix handles it correctly
✅ All translation extraction operations complete successfully

This fix ensures the pre-commit hook will work reliably even when run multiple times or when the node_modules directory is in an inconsistent state.

Original prompt

This section details on the original issue you should resolve

<issue_title>Can you investigate and fix this issue ?</issue_title>
<issue_description>### Story
Can you investigate and fix this issue ?

node-checks..............................................................................Passed
Check if translations files in 'frontend/xliff' need to be updated.......................Failed

  • hook id: check-translations
  • exit code: 2

🔎 Checking translations …
cd frontend && npm install && npm run translations:extract
npm warn deprecated rollup-plugin-terser@7.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-terser
npm warn deprecated @babel/plugin-proposal-dynamic-import@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-dynamic-import instead.
npm warn tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/work/search-a-licious/search-a-licious/frontend/node_modules/@custom-elements-manifest/analyzer/node_modules/typescript/lib/typescript.d.ts'
npm warn tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/work/search-a-licious/search-a-licious/frontend/node_modules/@custom-elements-manifest/analyzer/node_modules/typescript/lib/typescript.js'
npm warn tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/work/search-a-licious/search-a-licious/frontend/node_modules/@custom-elements-manifest/analyzer/node_modules/typescript/lib/typescriptServices.d.ts'
npm warn tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/work/search-a-licious/search-a-licious/frontend/node_modules/@custom-elements-manifest/analyzer/node_modules/typescript/lib/typescriptServices.js'
npm warn tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/work/search-a-licious/search-a-licious/frontend/node_modules/@custom-elements-manifest/analyzer/node_modules/typescript/lib/typesMap.json'
npm warn tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/work/search-a-licious/search-a-licious/frontend/node_modules/@custom-elements-manifest/analyzer/node_modules/typescript/lib/typingsInstaller.js'
npm warn tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/home/runner/work/search-a-licious/search-a-licious/frontend/node_modules/@custom-elements-manifest/analyzer/node_modules/typescript/lib/watchGuard.js'
npm warn tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/work/search-a-licious/search-a-licious/frontend/node_modules/@custom-elements-manifest/analyzer/node_modules/typescript/lib/zh-cn'
npm warn tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/work/search-a-licious/search-a-licious/frontend/node_modules/@custom-elements-manifest/analyzer/node_modules/typescript/lib/zh-tw'
npm warn tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/work/search-a-licious/search-a-licious/frontend/node_modules/@custom-elements-manifest/analyzer/node_modules/typescript/loc'
npm warn tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/work/search-a-licious/search-a-licious/frontend/node_modules/@custom-elements-manifest/analyzer/node_modules/typescript/loc'
npm warn tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/work/search-a-licious/search-a-licious/frontend/node_modules/@custom-elements-manifest/analyzer/node_modules/typescript/loc'
npm warn tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/work/search-a-licious/search-a-licious/frontend/node_modules/@custom-elements-manifest/analyzer/node_modules/typescript/loc'
npm warn tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/work/search-a-licious/search-a-licious/frontend/node_modules/@custom-elements-manifest/analyzer/node_modules/typescript/loc'
npm warn tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/work/search-a-licious/search-a-licious/frontend/node_modules/@custom-elements-manifest/analyzer/node_modules/typescript/loc'
npm warn tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/work/search-a-licious/search-a-licious/frontend/node_modules/@custom-elements-manifest/analyzer/node_modules/typescript/loc'
npm warn tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/work/search-a-licious/search-a-licious/frontend/node_modules/@custom-elements-manifest/analyzer/node_modules/typescript/loc'
npm warn tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/work/search-a-licious/search-a-licious/frontend/node_modules/@custom-elements-manifest/analyzer/node_modules/typescript/loc'
npm warn tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/home/runner/work/search-a-licious/search-a-licious/frontend/node_modules/@custom-elements-manifest/analyzer/node_modules/typescri...

Fixes #325


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Use npm ci instead of npm install and remove node_modules before installation to ensure a clean state. This prevents errors when npm install is run multiple times or when node_modules is corrupted.

Co-authored-by: teolemon <1689815+teolemon@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate and fix translation files issue Fix check_translations pre-commit hook failures due to corrupted node_modules Oct 13, 2025
Copilot AI requested a review from teolemon October 13, 2025 12:04
@teolemon teolemon changed the title Fix check_translations pre-commit hook failures due to corrupted node_modules fix: Fix check_translations pre-commit hook failures due to corrupted node_modules Nov 5, 2025
@github-project-automation github-project-automation bot moved this from Backlog (ready for dev) to In Progress in 🔎 Search-a-licious Nov 14, 2025
@alexgarel alexgarel marked this pull request as ready for review November 14, 2025 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Can you investigate and fix this issue ?

3 participants