Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
franc
✓ import { franc } from 'franc'
✗ import { franc } from 'franc-cli'
The `franc-cli` package is a command-line tool. For programmatic language detection within JavaScript/TypeScript applications, you should install and import from the `franc` library package. This library is ESM-only since v6.
francAll
✓ import { francAll } from 'franc'
✗ import { franc.all } from 'franc'
This function, from the `franc` library, was renamed from `franc.all` to `francAll` in `franc` v6. It is also ESM-only, requiring a native ES module import.
CommonJS require
✓ N/A
✗ const franc = require('franc')
The `franc` library, which `franc-cli` uses under the hood, became ESM-only in version 6.0.0. Attempting to `require()` it will result in a runtime error (`ERR_REQUIRE_ESM`).
This quickstart demonstrates how to programmatically execute the `franc-cli` command-line tool from a Node.js script using `child_process` and capture its output to detect the language of a given text string.
import { spawn } from 'child_process';
const textToAnalyze = "Alle menslike wesens word vry en gelyk in waardigheid en regte gebore.";
const child = spawn('franc-cli', [textToAnalyze]);
let output = '';
child.stdout.on('data', (data) => {
output += data.toString();
});
child.stderr.on('data', (data) => {
console.error(`stderr: ${data}`);
});
child.on('close', (code) => {
if (code === 0) {
console.log(`Detected language: ${output.trim()}`);
} else {
console.error(`franc-cli exited with code ${code}`);
}
});
franc --version
Debug
Known issues
breakingThe `franc` library, on which `franc-cli` is based, transitioned to an ESM-only package in version 6.0.0. Consequently, `franc-cli@8.0.0` and newer are also ESM-only. This means `require()` statements are no longer supported, and Node.js 12+ is required.fixMigrate your project to use ES modules (`import`/`export` syntax) and ensure you are running Node.js v12 or higher. For programmatic use, install and import from `franc` directly.
affects: >=8.0.0 (franc-cli), >=6.0.0 (franc)
breakingThe `franc` library's `franc.all()` method was renamed to `francAll()` in version 6.0.0 for better ESM compatibility and adherence to naming conventions.fixUpdate your code to use `francAll()` instead of `franc.all()` when importing the `franc` library.
affects: >=8.0.0 (franc-cli), >=6.0.0 (franc)
gotcha`franc-cli` is a command-line interface tool. It is not designed to be imported directly into JavaScript/TypeScript code as a library. For programmatic language detection, you should install and use the `franc` library package.fixIf you intend to use language detection programmatically, install `franc` (`npm install franc`) and import its functions. If you need to run `franc-cli` from a script, use `child_process.spawn` or similar methods.
affects: >=1.0.0
gotchaThe version numbers of `franc-cli` do not directly correlate with the `franc` library versions. For example, `franc-cli@8.0.0` is built upon `franc@6.x.x`. Always consult the monorepo's changelog for specific version dependencies and breaking changes affecting the underlying library.fixAlways refer to the official `franc` monorepo's documentation and changelog to understand the specific `franc` library version bundled with a given `franc-cli` release and any associated breaking changes.
affects: >=1.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/franc/index.js from /your/app.js not supported. Instead change the require of index.js in /your/app.js to a dynamic import() which is available in all CommonJS modules.
Attempting to `require()` the `franc` library (or any package depending on it internally) in a CommonJS module after `franc` became ESM-only.
fixMigrate your project or the specific file to use ES module syntax (`import { franc } from 'franc'`) and ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json`). TypeError: franc.all is not a function
Attempting to call `franc.all()` from the `franc` library after it was renamed to `francAll()` in v6.
fixUpdate your import and usage to `import { francAll } from 'franc'` and call `francAll()`. command not found: franc-cli
`franc-cli` was not installed globally or is not in your system's PATH.
fixInstall the package globally using `npm install -g franc-cli` or ensure that the directory containing the `franc-cli` executable is included in your system's PATH environment variable.
Audit
Dependencies
No dependency data recorded yet.