Summary
When @xenova/transformers is installed via a tool that blocks npm lifecycle scripts (e.g. npm with allowScripts disabled, or Pi's bundled installer which skips postinstall by default), semantic search is silently disabled with no actionable guidance.
Root cause
@xenova/transformers depends on sharp (native sharp-win32-x64.node binding).
sharp's install script (install/libvips + prebuilt binary fetch) is what produces that binding. If lifecycle scripts are skipped, the binding is absent.
src/embedder.ts does await import("@xenova/transformers") and on any throw prints:
pi-memory: @xenova/transformers not installed, semantic search disabled
- The actual underlying error is a missing native module (
Cannot find module '../build/Release/sharp-win32-x64.node'), not "transformers not installed". Users (and the agent running the install) are misled into thinking the package is simply absent.
Reproduction
- Install Pi, then
pi install npm:@samfp/pi-memory in an environment where npm install scripts are blocked.
- Start Pi and observe:
pi-memory: @xenova/transformers not installed, semantic search disabled.
node -e "import('@xenova/transformers')" → Cannot find module '../build/Release/sharp-win32-x64.node'.
Workaround (verified)
Inside the package dir, run npx prebuild-install (or node install/libvips + prebuild-install) so the prebuilt sharp binary is fetched; the import() then succeeds.
Suggested doc/UX improvements
- README / install docs: call out that semantic search needs
@xenova/transformers with its native sharp binary built, and that installers which skip postinstall scripts require a manual prebuild-install (or npm install --ignore-scripts=false).
- Clearer error: when the
import() fails, distinguish "package missing" from "native binary missing / script-blocked", and suggest the prebuild-install fix. This would have saved significant debugging time.
Semantic search itself works great once the native binary is present — this is purely a discoverability/install-friction issue.
Happy to PR a README note and/or a refined error message if you'd like.
Summary
When
@xenova/transformersis installed via a tool that blocks npm lifecycle scripts (e.g. npm withallowScriptsdisabled, or Pi's bundled installer which skips postinstall by default), semantic search is silently disabled with no actionable guidance.Root cause
@xenova/transformersdepends onsharp(nativesharp-win32-x64.nodebinding).sharp's install script (install/libvips+ prebuilt binary fetch) is what produces that binding. If lifecycle scripts are skipped, the binding is absent.src/embedder.tsdoesawait import("@xenova/transformers")and on any throw prints:Cannot find module '../build/Release/sharp-win32-x64.node'), not "transformers not installed". Users (and the agent running the install) are misled into thinking the package is simply absent.Reproduction
pi install npm:@samfp/pi-memoryin an environment where npm install scripts are blocked.pi-memory: @xenova/transformers not installed, semantic search disabled.node -e "import('@xenova/transformers')"→Cannot find module '../build/Release/sharp-win32-x64.node'.Workaround (verified)
Inside the package dir, run
npx prebuild-install(ornode install/libvips+prebuild-install) so the prebuiltsharpbinary is fetched; theimport()then succeeds.Suggested doc/UX improvements
@xenova/transformerswith its nativesharpbinary built, and that installers which skip postinstall scripts require a manualprebuild-install(ornpm install --ignore-scripts=false).import()fails, distinguish "package missing" from "native binary missing / script-blocked", and suggest theprebuild-installfix. This would have saved significant debugging time.Semantic search itself works great once the native binary is present — this is purely a discoverability/install-friction issue.
Happy to PR a README note and/or a refined error message if you'd like.