Repository navigation
Error loading sharp module on Android #74
|
TypeError: Cannot read properties of undefined (reading 'push') at Object.libvipsVersion (/data/data/com.termux/files/home/youtube-automation-agent-master/node_modules/sharp/node_modules/@img/sharp-wasm32/lib/sharp-wasm32.node.js:1:122617) at Object. (/data/data/com.termux/files/home/youtube-automation-agent-master/node_modules/sharp/lib/utility.js:14:30) at Module._compile (node:internal/modules/cjs/loader:1873:14) at Module._extensions..js (node:internal/modules/cjs/loader:2013:10) at Module.load (node:internal/modules/cjs/loader:1596:32) at Module._load (node:internal/modules/cjs/loader:1398:12) at wrapModuleLoad (node:internal/modules/cjs/loader:255:19) at Module.require (node:internal/modules/cjs/loader:1619:12) at require (node:internal/modules/helpers:191:16) at Object. (/data/data/com.termux/files/home/youtube-automation-agent-master/node_modules/sharp/lib/index.js:14:1) Node.js v26.3.1 |
Replies: 2 comments
|
This isn't Android-specific. It's an incompatibility between the old WebAssembly build of sharp that this project installs and newer versions of its runtime dependency On Termux there is no native sharp binary, so sharp falls back to I reproduced it on a desktop by forcing the wasm build ( Either of these fixes it (both tested on Node 26.3.1 with the wasm32 build, creating and encoding a PNG): Option 1, upgrade sharp (recommended). In "sharp": "^0.34.5"then reinstall: rm -rf node_modules package-lock.json
npm install --cpu=wasm32Option 2, keep sharp 0.33 and pin the runtime. Add this to "overrides": {
"@emnapi/runtime": "1.3.1"
}Check it with: node -e "require('sharp')({create:{width:4,height:4,channels:3,background:'#f00'}}).png().toBuffer().then(b=>console.log('sharp OK', b.length))"(Maintainers: bumping |
|
Thanks for the report, and thanks @freddysae0 for the diagnosis. That was exactly it: Termux has no native sharp binary, so sharp falls back to its WebAssembly build, and sharp 0.33 crashes with newer This is fixed on rm -rf node_modules
npm install --cpu=wasm32The project now needs Node.js 18.17 or newer. |

Thanks for the report, and thanks @freddysae0 for the diagnosis. That was exactly it: Termux has no native sharp binary, so sharp falls back to its WebAssembly build, and sharp 0.33 crashes with newer
@emnapi/runtimereleases.This is fixed on
master: sharp is now^0.34.5. Pull the latest code, then reinstall:The project now needs Node.js 18.17 or newer.