Home
Support Forums

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.