Next.js Discord

Discord Forum

Serverless function cannot find module

Unanswered
Goldstripe sardinella posted this in #help-forum
Open in Discord
Goldstripe sardinellaOP
Hi there, I'm using route handler serverless functions and have installed an npm package 'sharp' to run some image optimisations. Everything is working locally but after deploying to vercel the functions fail with Error: Cannot find module 'sharp' .

I've tried reinstalling node_modules with yarn and removing the lock file. None of this has helped. Any help is appreciated thank you.

It turns out that the package has native dependencies that need to be specifically installed.
Does anyone know how to do this?

7 Replies

Ojos Azules
I’m facing the same issue
Broad-snouted Caiman
me too
Broad-snouted Caiman
@Ojos Azules @Goldstripe sardinella Yo just got around this problem right now https://github.com/vercel/next.js/issues/56357
Had to downgrade next in my package.json "next": "13.5.4", to "next": "13.5.3",
and made a deployment into vercel
Satin Angora
I had to do the same thing.
13.5.3 is currently working while 13.5.4 is breaking in production on vercel