Install qrcode-terminal CLI globally
masterTo use qrcode-terminal as a standalone command-line tool, install it globally with npm:
npm install -g qrcode-terminal$ npm install -g qrcode-terminalrepository·master·Indexed 23 days ago
https://github.com/gtanner/qrcode-terminalA Node.js library and CLI tool for rendering QR codes directly within a terminal environment. Version 0.12.0 provides functionality to generate QR codes from strings, set error correction levels, and output results either directly to the console or via a callback function.
To use qrcode-terminal as a standalone command-line tool, install it globally with npm:
npm install -g qrcode-terminal$ npm install -g qrcode-terminalImport the library using require('qrcode-terminal'). You can generate QR codes directly to the terminal, set error correction levels, or capture the QR code as a string via a callback.
var qrcode = require('qrcode-terminal');
// Basic usage: displays to terminal
qrcode.generate('This will be a QRCode, eh!');
// Set error level (default is 'L')
qrcode.setErrorLevel('Q');
qrcode.generate('This will be a QRCode with error level Q!');
// Get QR code as a string via callback (does not display to terminal)
qrcode.generate('http://github.com', function (qrcode) {
console.log(qrcode);
});
// Small output mode
qrcode.generate('This will be a small QRCode, eh!', {small: true});
// Small output mode with callback
qrcode.generate('This will be a small QRCode, eh!', {small: true}, function (qrcode) {
console.log(qrcode);
});To use qrcode-terminal as a Node.js library in your project, install it using npm:
npm install qrcode-terminal$ npm install qrcode-terminalqrcode-terminal command to generate QR codes from arguments or piped input.The generate(input, opts, cb) method creates a QR code from the provided input string and outputs it to the terminal or via a callback.
Parameters:
input (string): The data to encode in the QR code.opts (object, optional): Configuration options.small (boolean): If true, uses special Unicode block characters (█, ▀, ▄) to render a more compact QR code. If false (default), uses ANSI color codes for a standard block output.cb (function, optional): A callback function that receives the generated string output. If no callback is provided, the output is printed directly to console.log.Behavior:
opts is omitted, it defaults to an empty object.opts is passed as a function, it is treated as the callback cb.The setErrorLevel(error) method sets the error correction level for subsequent generate() calls. It uses levels defined in the internal QRErrorCorrectLevel mapping.
Parameters:
error (string): The name of the error correction level. If the provided string does not match a valid level, the current level is retained.Note: The default error level is QRErrorCorrectLevel.L.
The following flags and arguments are supported by the qrcode-terminal command-line interface:
Usage: qrcode-terminal <message>
Options:
-h, --help output usage information
-v, --version output version numberqrcode-terminal CLI allows you to render QR codes directly in your terminal. You can provide the input message either as a command-line argument or by piping text via stdin.L error correction level, which is exported as qrcode.error.