{"id":16086,"library":"igc-parser","title":"IGC Flight Log Parser","description":"igc-parser is a JavaScript/TypeScript library designed for parsing IGC flight log files, a standard format used for recording flights in gliders, balloons, and other unpowered aircraft. The current stable version is 2.0.0. The project maintains an active development pace, with releases occurring periodically to introduce enhancements and address breaking changes, as seen with versions 0.5.0, 1.0.0, 1.1.0, and 2.0.0. Key differentiators include its robust handling of various IGC record types (such as A, B, H, L records), support for specific extensions like LAD/LOD for B records, GeoDatum handling, and parsing of TZN timezone headers. It also offers a `lenient` parsing option, allowing processing of files even with minor errors. The library ships with comprehensive TypeScript type definitions, making it well-suited for modern TypeScript projects.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/Turbo87/igc-parser","tags":["javascript","typescript"],"install":[{"cmd":"npm install igc-parser","lang":"bash","label":"npm"},{"cmd":"yarn add igc-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add igc-parser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The primary parsing function is a named export. There is no default export from the library, so a default import will yield `undefined`.","wrong":"import IGCParser from 'igc-parser';","symbol":"parse","correct":"import { parse } from 'igc-parser';"},{"note":"This is the modern CommonJS import for directly accessing the named `parse` function. Importing the entire module without destructuring will assign the module object to `parse`, leading to a `TypeError`.","wrong":"const parse = require('igc-parser');","symbol":"parse (CommonJS, destructuring)","correct":"const { parse } = require('igc-parser');"},{"note":"This reflects the original usage example in the README, where `IGCParser` refers to the entire module object, which has a `parse` method. `IGCParser` itself is not a named export.","wrong":"const { IGCParser } = require('igc-parser');","symbol":"parse (CommonJS, object access)","correct":"const IGCParser = require('igc-parser');\n// ...\nlet result = IGCParser.parse(fileContent);"},{"note":"Import the `IGCFile` type for strong typing of the parsing result object in TypeScript projects.","symbol":"IGCFile (TypeScript Type)","correct":"import { IGCFile } from 'igc-parser';"}],"quickstart":{"code":"import { parse } from 'igc-parser';\nimport { readFileSync, writeFileSync } from 'fs';\nimport { join } from 'path';\n\n// Example IGC content (simplified for brevity, typically much longer)\nconst igcContent = `AXXXLXNAV;LX8000,FW:2.0\\nHFDTE150717\\nHFCIDJohn Doe\\nHOTYPESHW-222\\nHOREGISTRATIOND-2019\\nI013638FXA\\nB1018265101070N00701006E00049000-42\\nB1018275101071N00701007E00050000-43\\nLGC-2023-01-01T12:00:00Z\\n60DC059E2D2F6CAD2E889224E355DBDDB805CAB100000639B49FC5F280A292C990F554789F12381380720000`;\n\n// Create a temporary file to demonstrate reading from disk\nconst tempFilePath = join(__dirname, 'temp.igc');\nwriteFileSync(tempFilePath, igcContent, 'utf8');\n\ntry {\n  const fileContent = readFileSync(tempFilePath, 'utf8');\n  // Parse the IGC file content, allowing for minor errors with lenient mode\n  const result = parse(fileContent, { lenient: true });\n\n  console.log('Successfully parsed IGC file:');\n  console.log(`Date: ${result.date}`);\n  console.log(`Pilot: ${result.pilot}`);\n  console.log(`Glider Type: ${result.gliderType}`);\n  console.log(`Number of Fixes: ${result.fixes.length}`);\n  console.log(`First Fix Time: ${result.fixes[0]?.time}`);\n  console.log(`Last Fix Time: ${result.fixes[result.fixes.length - 1]?.time}`);\n\n} catch (error) {\n  console.error('Error parsing IGC file:', error);\n} finally {\n  // In a production application, you might remove the temporary file here.\n  // import { unlinkSync } from 'fs';\n  // unlinkSync(tempFilePath);\n}","lang":"typescript","description":"Demonstrates how to parse an IGC flight log string, including reading from a temporary file, handling the parsing options (e.g., `lenient` mode), and logging key extracted information like flight date, pilot, glider type, and fix details."},"warnings":[{"fix":"Upgrade your Node.js environment to version 12 or higher. It is recommended to use a Node.js version currently in active LTS.","message":"Version 1.0.0 of `igc-parser` officially dropped support for Node.js versions 10 and below. Users running on these older Node.js runtimes will encounter errors and must upgrade their environment.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"If you encounter new parsing errors with existing IGC files, try enabling the `lenient: true` option in the `parse` function: `parse(content, { lenient: true });`. Additionally, review your IGC files to ensure they strictly conform to the IGC specification for 'A' records.","message":"Version 0.5.0 introduced a more robust and possibly stricter regular expression for parsing 'A' records within IGC files. This change might cause previously parsable, but malformed, IGC files to now fail parsing in strict mode.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Always use named imports for ESM (`import { parse } from 'igc-parser';`) or destructuring for CommonJS (`const { parse } = require('igc-parser');`) if you wish to directly access the `parse` function.","message":"`igc-parser` provides its primary functionality, including the `parse` function, as named exports. Attempting to use a default import (`import IGCParser from 'igc-parser';`) will result in `undefined` for `IGCParser` and subsequent runtime errors when trying to call its methods.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"For CommonJS, use object destructuring to correctly import the named `parse` export: `const { parse } = require('igc-parser');`.","cause":"This error typically occurs in CommonJS environments when attempting to import the `parse` function without destructuring, e.g., `const parse = require('igc-parser');` instead of `const { parse } = require('igc-parser');`.","error":"TypeError: parse is not a function"},{"fix":"Use a named import for the `parse` function: `import { parse } from 'igc-parser';`.","cause":"This error indicates that you've likely used a default import (`import IGCParser from 'igc-parser';`) in an ESM module, but `igc-parser` does not have a default export. Thus, `IGCParser` is `undefined`, and you cannot access a property `parse` on it.","error":"TypeError: Cannot read properties of undefined (reading 'parse')"},{"fix":"Pass the `{ lenient: true }` option to the `parse` function to allow it to continue processing even with minor formatting errors: `parse(content, { lenient: true });`. If errors persist, thoroughly review and correct the IGC file's structure.","cause":"The input IGC file content is malformed, corrupted, or does not strictly adhere to the IGC specification, and the parser is operating in its default strict mode.","error":"Error: Invalid IGC format (or specific parsing error related to 'A', 'B', 'H' records, etc.)"}],"ecosystem":"npm"}