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

require('canvas') errors in bindings.CanvasRenderingContext2dInit is not a function #1440

Closed
snajjar opened this issue Jun 7, 2019 · 4 comments

Comments

@snajjar
Copy link

snajjar commented Jun 7, 2019

Currently, after a classic install of canvas 2.5.0 from npm, require('canvas') is not working:

TypeError: bindings.CanvasRenderingContext2dInit is not a function
at Object.<anonymous> (/mypath/node_modules/canvas/lib/context2d.js:13:10)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)

Issue or Feature

Investigating this, i found that requiring canvas/build/Release/canvas.node would give the following result:

> require('./canvas.node')
{ Canvas: [Function: Canvas],
Image: { [Function: Image] MODE_IMAGE: 1, MODE_MIME: 2 },
ImageData: [Function: ImageData],
CanvasRenderingContext2d: [Function: CanvasRenderingContext2D],
CanvasGradient: [Function: CanvasGradient],
CanvasPattern: [Function: CanvasPattern],
FontFace: [Function: FontFace],
cairoVersion: '1.16.0',
jpegVersion: '8',
gifVersion: '5.1.4',
freetypeVersion: '2.9.1' }

What's expected from this is the CanvasRenderingContext2dInit method but the object only provide a CanvasRenderingContext2d

Steps to Reproduce

Just install and require canvas with my environment.

Your Environment

canvas 2.5.0
node 8.15.0
Linux 4.20

@zbjornson
Copy link
Collaborator

This might be a variant of #1250 (mismatch of JS and C++ code). You seem to have JS from version 2.2 or later, and C++ from pre-2.2. Can you try a totally from-scratch install (delete node_modules)?

@zbjornson
Copy link
Collaborator

If you're still having issues, leave a comment and I'll reopen this.

@jessepinho
Copy link

Just an update that I'm experiencing this too when building for AWS Lambda

@DeviousM
Copy link

DeviousM commented Dec 2, 2020

I have the same issue now with the newest version.

TypeError: bindings.CanvasRenderingContext2dInit is not a function
at Object.../../node_modules/canvas/lib/context2d.js (/mypath/node_modules/canvas/lib/context2d.js:13:1)

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

4 participants