question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Node.js new Image() is not defined

See original GitHub issue

Node.js v4.2.4

var QRC = require('qrcode-reader');
var reader = new QRC();

reader.callback = function(result){
    console.log(result);
};

reader.decode("alice_shocked.png");

Result: ** ReferenceError: Image is not defined at decode … qrcode-reader\dist\index.js:2326**

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:19 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
edi9999commented, Jul 2, 2016

I don’t know exactly for now how we could be using Image from inside node, and not in the browser build.

In the meantime, you can do something like this before requiring jsqrcode:

npm install canvas

then in your code :

var Canvas = require("canvas");
global.Image = Canvas.Image;
Read more comments on GitHub >

github_iconTop Results From Across the Web

ReferenceError: Image is not defined - Stack Overflow
This gives me a ReferenceError: Image() is not defined. If I try to use document.createElement("img"); it says "document is not defined". How ...
Read more >
Getting the "img not defined" reference error in the console
In "fetchBreedImage", a variable named "image" is defined; but references are made to "img", which is not defined. And to make it easier...
Read more >
How to fix "require is not defined" in JavaScript / Node.js?
Learn what is "require-is-not-defined" error in JavaScript, when they occur, and how you can fix it in both browser and Node.js environment.
Read more >
Image JavaScript and Node.js code examples - Tabnine
Best JavaScript code snippets using Image(Showing top 15 results out of 4,743) ; function loadImage(image) { return new Promise((resolve) => { if (typeof...
Read more >
Creating and saving images with node-canvas - LogRocket Blog
Did you know you can use Node.js to generate a meta image for some pieces of content, like a blog post? Learn more...
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