Cloudflare pages preset

Hi, if I'm hosting my nuxt app in cloudflare, do I need to still set this preset?
nitro: {
preset: 'cloudflare-pages',
},
nitro: {
preset: 'cloudflare-pages',
},
The reason I ask, is that I want to do some image manipulation in my api route so I'm using sharp but this doesnt seem compatible when I use that preset? I guess this is out of the realm of here - but - is there another image manipulation library I can do which is compatible with cloudflare pages environment? Thanks
2 Replies
AGill
AGill5w ago
I was able to deploy sharp -- see issues comment: https://github.com/lovell/sharp/issues/4113#issuecomment-2560374164 But now I'm getting some runtime errors so I need to figure that out:
Could not load the \"sharp\" module using the linuxnull-undefined runtime\nundefined: Could not dynamically require \"../src/build/Release/sharp-linuxnull-undefined.node\". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.\nundefined: Could not dynamically require \"../src/build/Release/sharp-wasm32.node\". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.\nundefined: Could not dynamically require \"@img/sharp-linuxnull-undefined/sharp.node\". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.\nundefined: Could not dynamically require \"@img/sharp-wasm32/sharp.node\". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.\nPossible solutions:\n- Manually install libvips >= 8.15.3\n- Add experimental WebAssembly-based dependencies:\n npm install --cpu=wasm32 sharp\n npm install @img/sharp-wasm32\n- Consult the installation documentation:\n See https://sharp.pixelplumbing.com/install\n"
Could not load the \"sharp\" module using the linuxnull-undefined runtime\nundefined: Could not dynamically require \"../src/build/Release/sharp-linuxnull-undefined.node\". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.\nundefined: Could not dynamically require \"../src/build/Release/sharp-wasm32.node\". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.\nundefined: Could not dynamically require \"@img/sharp-linuxnull-undefined/sharp.node\". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.\nundefined: Could not dynamically require \"@img/sharp-wasm32/sharp.node\". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.\nPossible solutions:\n- Manually install libvips >= 8.15.3\n- Add experimental WebAssembly-based dependencies:\n npm install --cpu=wasm32 sharp\n npm install @img/sharp-wasm32\n- Consult the installation documentation:\n See https://sharp.pixelplumbing.com/install\n"
GitHub
Nuxt build failed on Cloudflare Pages. Cannot resolve "@img/sharp-w...
Possible bug Is this a possible bug in a feature of sharp, unrelated to installation? Running npm install sharp completes without error. Running node -e "require('sharp')" complet...
AGill
AGill3w ago
lol fair point I ended up using jsquash: https://github.com/jamsinclair/jSquash
GitHub
GitHub - jamsinclair/jSquash: Browser & Web Worker focussed image c...
Browser & Web Worker focussed image codec wasm bundles derived from the Squoosh App. - jamsinclair/jSquash

Did you find this page helpful?