import sharp from sharp
sharp(image)
.toBuffer((err, data, info) => {
console.log(err, data, info)
});
ModuleNotFoundError: Module not found: Error: Can't resolve 'fs' in '/xxxxx/...../node_modules/detect-libc/lib'
ModuleNotFoundError: Module not found: Error: Can't resolve 'child_process' in '/xxxxx/...../node_modules/webp-converter/src'
./node_modules/sharp/build/Release/sharp-darwin-x64.node
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
そもそもブラウザ上ではSharpは動かないことが原因。
Hi, sharp requires the Node.js runtime and will not work in a browser.
別の方法でWebPへの変換を行った。