Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document is not defined (using browser.js version instead of canvas.node) #2412

Open
1 task
0xraffa opened this issue Jul 25, 2024 · 2 comments
Open
1 task

Comments

@0xraffa
Copy link

0xraffa commented Jul 25, 2024

Issue or Feature

For some reason I am unable to create a canvas on NodeJS because it keeps failing with the "document is not defined" error coming from the browser.js. I installed it using 'yarn add canvas' and expected it to work as expected.

Steps to Reproduce

import * as Canvas from 'canvas'
var canvas = Canvas.createCanvas(200, 200);

Your Environment

  • Version of node-canvas (output of npm list canvas or yarn list canvas): 2.11.2
  • Environment (e.g. node 20.9.0 on macOS 14.1.1): node 20.10.0 on macOS 14.0. Used in a API App Route on a NextJS website
@aitorxoborg
Copy link

Same problem here

@zbjornson
Copy link
Collaborator

browser.js shouldn't be loaded when running in Node.js - package.json specifies "main": "index.js" and "browser": "browser.js". Can you provide reproduction steps please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants