I am trying to import and use sharp
in my Next.js project. I have tried uninstalling and reinstalling sharp
many times but every time I run npm run dev
, this is the error I get.
./node_modules/detect-libc/lib/detect-libc.js:3:0
Module not found: Can't resolve 'child_process'
Import trace for requested module:
./node_modules/sharp/lib/utility.js
./node_modules/sharp/lib/index.js
./pages/index.js
https://nextjs.org/docs/messages/module-not-found
For reference this is the code that is causing the error:
import sharp from "sharp";
I have also tried this code, with no success:
const sharp = require('sharp');
Every other dependency I have installed works except for sharp
.