Commit f364da6
authored
fix: use require.resolve() for exec-child.js path to fix Next.js/webp… (#1259)
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.1 parent ed9f79a commit f364da6
1 file changed
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
8 | 14 | | |
9 | 15 | | |
10 | 16 | | |
| |||
78 | 84 | | |
79 | 85 | | |
80 | 86 | | |
81 | | - | |
| 87 | + | |
82 | 88 | | |
83 | 89 | | |
84 | 90 | | |
| |||
0 commit comments