createCanvas is not a function

See original GitHub issue

I’m trying to use prismarine-viewer.headless, specifically with this line: viewer(mc, { output: 'pov.png', frames: 1, width: 1920, height: 1080 }); However, upon executing that line, this error pops out:

/project/node_modules/prismarine-viewer/lib/headless.js:18
  const canvas = createCanvas(width, height)
                 ^

TypeError: createCanvas is not a function
    at module.exports (/project/node_modules/prismarine-viewer/lib/headless.js:18:18)
    at Client.<anonymous> (/project/bot.js:58:5)
    at Client.emit (events.js:315:20)
    at MessageCreateAction.handle (/project/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (/project/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (/project/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
    at WebSocketShard.onPacket (/project/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (/project/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
    at WebSocket.onMessage (/project/node_modules/ws/lib/event-target.js:132:16)
    at WebSocket.emit (events.js:315:20)

To add: prismarine-viewer is on 1.17.0, and mineflayer is on 3.2.0. Edit: Updated prismarine-viewer to 1.18.0 and mineflayer to 3.3.1; no difference.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Karangcommented, Mar 14, 2021

Just tried the example/headless.js script with latest version, no issues. Can you please make sure that node-canvas-webgl is actually installed. You can also try to run the example to check if the issue is coming from your script.

0reactions
Permanentlycommented, Mar 14, 2021

Ah right- looks like a lot more than the original line I had used; nevertheless, will give it a shot. Cheers!

Read more comments on GitHub >

github_iconTop Results From Across the Web

canvas not working after successful install -> createCanvas is ...
canvas not working after successful install -> createCanvas is not a function #1073. Closed. nbremer opened this issue on Jan 3, ...
Read more >
Discord.js making an image using canvas throws an error ...
I'm trying to make an image using canvas but i get error "Canvas.createCanvas is not a function ...
Read more >
canvas.createCanvas JavaScript and Node.js code examples
function prepareCanvas(size){ canvas = createCanvas(...size);
Read more >
reference | createCanvas() - P5.js
function setup() { createCanvas(100, 50); background(153); line(0, 0, ... Renderer is not set) the origin (0,0) is positioned at the top left of...
Read more >
canvas - npm
const { createCanvas, loadImage } = require('canvas') const canvas ... To use a font file that is not installed as a system font, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found