patorjk / figlet.js

A FIG Driver written in JavaScript which aims to fully implement the FIGfont spec.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error with example code?

CubexsOne opened this issue · comments

I installed Figlet and inserted the sample code into my code via Copy & Paste.

var figlet = require('figlet');
 
figlet('Hello World!!', function(err, data) {
    if (err) {
        console.log('Something went wrong...');
        console.dir(err);
        return;
    }
    console.log(data)
});

The following message appears in the browser's console:

Something went wrong...

Error: FIGlet header contains invalid values.
    at Function.me.parseFont (http://localhost:1234/main.c138d377.js:1148:13)
    at http://localhost:1234/main.c138d377.js:1265:21

That sample code is from the "Quick Start - Node.js" section, it only works in Node.js. You want to look at the "Getting Started - The Browser" section, it provides an example of how to use the library in the browser.

So there is no way to use this via NodeJs - Parcel-bundler and Frameworks like Angular oder React?
Hast Fetch any NPM Package?

Thanks for the answer.

See my example code here for using the library with bundlers like webpack: #32 (comment)

Ahh perfect, maybe u can add this to the "Getting Started - The Browser" section like a tip or something like this.

This worked perfectly for me :)

Thank you and have a nice day.