Shashank3736 / captcha-canvas

A captcha generator by using skia-canvas.
https://captcha-canvas.js.org
Apache License 2.0
61 stars 12 forks source link

Fontconfig error: Cannot load default config file #20

Closed Veinify closed 3 years ago

Veinify commented 4 years ago

I don't really know how i got this error for some reason. It doesn't showed up before. The only thing i did was updating my node modules(without changing the version). I'm using the latest version. Anyways heres the code that i use:

const captchacode = randomBytes(32).toString("hex").substr(0, 6);
const { CaptchaGenerator } = require('captcha-canvas');
const captcha = new CaptchaGenerator()
.setDimension(150, 450) 
.setCaptcha({text: captchacode, size: 60, color: message.guild.me.displayHexColor})
.setDecoy({opacity: 0.5})
.setTrace({color: message.guild.me.displayHexColor});
const buffer = captcha.generateSync();

And the captcha image looks like this Verification

Shashank3736 commented 4 years ago

The issue here is canvas module. And maybe a problem with your computer. You can see an issue on this topic here.

You can also try to use solutions mention here

Veinify commented 3 years ago

Hmm it doesn't really help much... I tried to reinstall it by using npm install --build-from-source canvas but it just keep failing. If i try to use npm rebuild nothing changes. Also updating the node-gyp but still nothing changed

F0rce commented 3 years ago

@Veinify this seems to be a super late reply, but maybe you already solved it. I solved it by typing the command: apt-get install fontconfig

Node-Canvas requires this package to do text writing. With installing that package the config file is automatically generated unter /etc/fonts and everything works after a restart.

Hope you have a great day, David