Skip to content

Can't resolve 'canvas' on next.js serverless app #54

@EnricoNapolitan

Description

@EnricoNapolitan

What's the problem

I built a next.js application with serveless option, but simply importing this library it throws this error:

Failed to compile.
ModuleNotFoundError: Module not found: Error: Can't resolve 'canvas' in '/.../node_modules/jsdom/lib/jsdom'
> Build error occurred

I already tried to add canvas library but this doesn't fix the problem and it throws another error.

Step to reproduce

Add to next.config.js:

module.exports = {
  target: 'serverless'
}

Run next build

Basic Info:

  • "isomorphic-dompurify": "^0.12.0",
  • "next": "^10.0.8",
  • "react": "^17.0.1",
  • "react-dom": "^17.0.1"

This issue could be related to #35 , but i don't use umijs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions