Skip to content

fix: use require.resolve() for exec-child.js path to fix Next.js/webp…#1259

Merged
nfischer merged 1 commit into
shelljs:mainfrom
CodeAurelius0:main
Jun 30, 2026
Merged

fix: use require.resolve() for exec-child.js path to fix Next.js/webp…#1259
nfischer merged 1 commit into
shelljs:mainfrom
CodeAurelius0:main

Conversation

@CodeAurelius0

Copy link
Copy Markdown
Contributor

…ack bundler compatibility (#1158)

When Next.js (or any webpack-based bundler) bundles the server-side code, __dirname is replaced with the bundled output directory (e.g. .next/server/vendor-chunks/). This causes child_process.execFileSync to look for exec-child.js in the wrong location, leading to the 'Cannot find module' error.

Fix: resolve exec-child.js path using require.resolve() at module load time. require.resolve() always returns the real filesystem path of the module, unaffected by bundler __dirname transformations.

…ack bundler compatibility (shelljs#1158)

When Next.js (or any webpack-based bundler) bundles the server-side code,
__dirname is replaced with the bundled output directory (e.g. .next/server/vendor-chunks/).
This causes child_process.execFileSync to look for exec-child.js in the wrong location,
leading to the 'Cannot find module' error.

Fix: resolve exec-child.js path using require.resolve() at module load time.
require.resolve() always returns the real filesystem path of the module,
unaffected by bundler __dirname transformations.
@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.10%. Comparing base (ed9f79a) to head (8b63e2d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1259   +/-   ##
=======================================
  Coverage   97.09%   97.10%           
=======================================
  Files          36       36           
  Lines        1517     1518    +1     
=======================================
+ Hits         1473     1474    +1     
  Misses         44       44           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nfischer nfischer merged commit f364da6 into shelljs:main Jun 30, 2026
17 checks passed
@nfischer nfischer added exec Issues specific to the shell.exec() API Bundler labels Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bundler exec Issues specific to the shell.exec() API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants