Commit 499b849
fix(search-install): skip optional deps (sharp) + augment PATH for npm subprocesses
User report 2026-05-19: with the previous Windows fixes in place, npm
install actually started running successfully — got past the EINVAL,
downloaded packages — but failed on @huggingface/transformers'
optional `sharp` dependency:
npm error path C:\...\runtime\node_modules\sharp
npm error command C:\WINDOWS\system32\cmd.exe /d /s /c
node install/check.js || npm run build
npm error 'node' is not recognized as an internal or external command
Two underlying issues:
(A) sharp is an image-processing library that's an optional dependency
of @huggingface/transformers. Our use case is text embeddings only
(Xenova MiniLM), so we don't need sharp. Skip it with
`--omit=optional`. As a bonus this also avoids pulling
onnxruntime-web — we only want onnxruntime-node.
(B) sharp's postinstall script shells out to cmd.exe which does its
own PATH lookup for `node`. On a Windows machine with no system
Node installed (our target user), this fails. The bundled
node.exe we're running from isn't on the user's PATH.
Fix (B) by augmenting PATH in the spawn env: prepend
dirname(process.execPath) to the PATH passed to the npm child
process. Now any postinstall script invoked via cmd.exe can
resolve `node` and `npm` from the bundled runtime. Belt-and-
braces for future deps with similar postinstalls.
After this fix the npm install completes with the text-only stack
intact. The user can stay on bundled Node, no system Node ever
required.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 9539fbe commit 499b849
1 file changed
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
102 | 110 | | |
103 | 111 | | |
104 | 112 | | |
| |||
108 | 116 | | |
109 | 117 | | |
110 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
111 | 127 | | |
112 | 128 | | |
113 | 129 | | |
| 130 | + | |
114 | 131 | | |
115 | 132 | | |
116 | 133 | | |
| |||
0 commit comments