#Route GET with @napi-rs/canvas

1 messages · Page 1 of 1 (latest)

cunning dawnBOT
#

Hi @north pike. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

The error message you're seeing is related to Webpack not being able to process the binary file from the @napi-rs/canvas package. This is a common issue when trying to use native Node.js addons with Next.js, as seen in the Github issue #59648 (https://github.com/vercel/next.js/issues/59648) and Github issue #43050 (https://github.com/vercel/next.js/issues/43050).

One possible solution is to modify your next.config.js to handle these types of files. Here's an example from the Github issue #43050 (https://github.com/vercel/next.js/issues/43050) where a similar problem was solved:

const nextConfig = {
  reactStrictMode: false,
  webpack: (config) => {
    config.externals.push({
      sharp: "commonjs sharp",
      canvas: "commonjs canvas"
    })
    return config
  },
}

In this example, sharp and canvas are being added to the externals array in the Webpack configuration. You might need to replace sharp and canvas with the appropriate package names for your project.

Please note that this is a workaround and might not work in all cases. If the problem persists, I recommend opening an issue in the Next.js GitHub repository.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@north pike kapa.ai is still learning and improving, please let us know how it did by reacting below

north pike
north pike
#

@cunning dawn

cunning dawnBOT
#

Let me check the knowledge base for you. One moment! :books: