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

Unhandled error and empty image #22

Open
parth0595 opened this issue Jun 29, 2017 · 6 comments
Open

Unhandled error and empty image #22

parth0595 opened this issue Jun 29, 2017 · 6 comments

Comments

@parth0595
Copy link

var barcode = require('barcode');
var path = require('path');
var code128 = barcode('code128', {
    data: "r1001-20160906-0001",
    width: 500,
    height: 100,
});
var outfile = path.join(__dirname, 'imgs', 'mm.png');
code128.saveImage(outfile, function (err) {

    if (err) throw err;
    console.log('File has been written!');

});

this is what I get.

throw er; // Unhandled 'error' event
      ^
Error: spawn gm ENOENT
    at exports._errnoException (util.js:1050:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:367:16)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
    at Module.runMain (module.js:607:11)
    at run (bootstrap_node.js:427:7)
    at startup (bootstrap_node.js:151:9)
    at bootstrap_node.js:542:3

It generates an empty image .

@parth0595
Copy link
Author

Found the solution. it works fine after installing graphics magic. @samt Is there any way we can use labels on top of the barcode generated?

@ripu502
Copy link

ripu502 commented Apr 29, 2019

for Linux (Ubuntu) user, you can solve this problem by running this in terminal
sudo npm install --save gm
sudo apt install graphicsmagick
if the error continue :
sudo npm install --save graphicsmagick
sudo npm install --save imagemagick

@Tanumay92
Copy link

Is there any way to solve in windows?? As I have already installed graphicsMagick.

@ripu502
Copy link

ripu502 commented Jun 6, 2019 via email

@Tanumay92
Copy link

Its solved... @ripu502

@Hirurgo
Copy link

Hirurgo commented Aug 23, 2019

@ripu502 For windows you need to install graphicsMagick application from official site http://www.graphicsmagick.org/ and restart your computer

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

No branches or pull requests

4 participants