Fabric.js on Next.js > TypeError: Cannot read properties of undefined (reading ‘Canvas’) > const canvas = new fabric.Canvas(canvasRef.current, {
While creating a Figma Clone with Next.js, I’m getting the following error when importing fabric.js. Applying the suggestions from Claude temporarily solves the issue, but it seems this isn’t the right approach as I have to modify all the functions in shapes.ts individually. There’s already a red underline under fabric when importing. When I run ‘npm install fabric’, it says “This package is no longer supported.” The instructor’s code runs fine with the same code, but mine doesn’t. I can’t find much when searching. How should I resolve this?