Nextjs deploy error after installing remark-prism package

After installing remark-prism, I get this deploy error:

ModuleNotFoundError: Module not found: Error: Can't resolve 'canvas' in '/opt/build/repo/node_modules/jsdom/lib/jsdom'

The build does not fail locally, and the dev server also works fine.

It is mentioned in this github issue comment, but I am unsure of what the actual cause is, or how to fix it.

The cause is that, the dependency needs another dependency which might not be installed. You might try installing the dependency yourself by adding it your package.json or try another workaround mentioned in that thread: Serverless build fails with: ModuleNotFoundError: Module not found: Error: Can't resolve 'aws-sdk' · Issue #16618 · vercel/next.js · GitHub.

Did you end up getting this to work? I am having the same issue.

Hi @thefinnomenon,

Have you tried the workarounds mentioned in the issue above? Can you share your progress with those?

Did you have a fix on this issue? Facing same issue but no response from anyone. Official Website

Hi @Richard0017,

Same question for you too. Have you tried what’s suggested above?