{"id":17006,"library":"franc-cli","title":"franc-cli: Language Detection CLI","description":"franc-cli is a command-line interface (CLI) tool for detecting the natural language of textual input. It acts as a convenient shell wrapper around the core `franc` library, which supports identifying over 180 languages, including various scripts and dialects. The current stable version for `franc-cli` is 8.0.0, which corresponds to breaking changes introduced in `franc` library versions 6.x.x. The project generally follows the `franc` library's release cadence, with updates often driven by new Unicode versions or improvements in language detection models. Its key differentiator is providing quick, direct command-line access to language detection without requiring programmatic integration, making it suitable for shell scripting, data processing pipelines, and rapid prototyping. It is an ESM-only package, requiring Node.js version 12 or higher for execution.","status":"active","version":"8.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/wooorm/franc#main","tags":["javascript","natural","language","writing","system","detect","guess","cli","bin"],"install":[{"cmd":"npm install franc-cli","lang":"bash","label":"npm"},{"cmd":"yarn add franc-cli","lang":"bash","label":"yarn"},{"cmd":"pnpm add franc-cli","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"import { franc } from 'franc-cli'","symbol":"franc","correct":"import { franc } from 'franc'"},{"note":"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.","wrong":"import { franc.all } from 'franc'","symbol":"francAll","correct":"import { francAll } from 'franc'"},{"note":"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`).","wrong":"const franc = require('franc')","symbol":"CommonJS require","correct":"N/A"}],"quickstart":{"code":"import { spawn } from 'child_process';\n\nconst textToAnalyze = \"Alle menslike wesens word vry en gelyk in waardigheid en regte gebore.\";\n\nconst child = spawn('franc-cli', [textToAnalyze]);\n\nlet output = '';\nchild.stdout.on('data', (data) => {\n  output += data.toString();\n});\n\nchild.stderr.on('data', (data) => {\n  console.error(`stderr: ${data}`);\n});\n\nchild.on('close', (code) => {\n  if (code === 0) {\n    console.log(`Detected language: ${output.trim()}`);\n  } else {\n    console.error(`franc-cli exited with code ${code}`);\n  }\n});","lang":"typescript","description":"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."},"warnings":[{"fix":"Migrate 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.","message":"The `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.","severity":"breaking","affected_versions":">=8.0.0 (franc-cli), >=6.0.0 (franc)"},{"fix":"Update your code to use `francAll()` instead of `franc.all()` when importing the `franc` library.","message":"The `franc` library's `franc.all()` method was renamed to `francAll()` in version 6.0.0 for better ESM compatibility and adherence to naming conventions.","severity":"breaking","affected_versions":">=8.0.0 (franc-cli), >=6.0.0 (franc)"},{"fix":"If 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.","message":"`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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always 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.","message":"The 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Migrate 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`).","cause":"Attempting to `require()` the `franc` library (or any package depending on it internally) in a CommonJS module after `franc` became ESM-only.","error":"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."},{"fix":"Update your import and usage to `import { francAll } from 'franc'` and call `francAll()`.","cause":"Attempting to call `franc.all()` from the `franc` library after it was renamed to `francAll()` in v6.","error":"TypeError: franc.all is not a function"},{"fix":"Install 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.","cause":"`franc-cli` was not installed globally or is not in your system's PATH.","error":"command not found: franc-cli"}],"ecosystem":"npm","meta_description":null}