@itissandeep,
CanvasJS is a client-side library and has to be prevented from rendering at server-side. When you try to generate build for production, it causes issue with libraries that depend on the browser’s window object. You can import CanvasJS package dynamically by passing ssr: false
that disables importing of components that are not needed for SSR. Please take a look at this sample project for a working example on adding CanvasJS React Charts in Next.js app.

Also, please refer to this article for more information on adding CanvasJS chart in Next.js apps.
—
Vishwas R
Team CanvasJS