Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@linuxcnc-node/gcode

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@linuxcnc-node/gcode

Node.js G-code parser using LinuxCNC rs274ngc interpreter

latest
Source
npmnpm
Version
2.2.2
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

@linuxcnc-node/gcode

G-code file parser for Node.js using LinuxCNC's rs274ngc interpreter. Parse G-code files and extract sequential operations for toolpath visualization.

Installation

npm install @linuxcnc-node/gcode

Usage

import { parseGCode } from "@linuxcnc-node/gcode";
import { OperationType, PositionIndex } from "@linuxcnc-node/types";

const result = await parseGCode("/path/to/program.ngc", {
  iniPath: "/path/to/linuxcnc.ini",
  onProgress: (p) => console.log(`${p.percent}% - ${p.operationCount} ops`),
});

console.log(`Parsed ${result.operations.length} ops`, result.extents);

const { X, Y, Z } = PositionIndex;
for (const op of result.operations) {
  if (op.type === OperationType.TRAVERSE) {
    console.log(`Rapid to ${op.pos[X]}, ${op.pos[Y]}, ${op.pos[Z]}`);
  } else if (op.type === OperationType.FEED) {
    console.log(`Feed to ${op.pos[X]}, ${op.pos[Y]} @ F${op.feedRate}`);
  }
}

API

parseGCode(filepath, options)

Returns Promise<GCodeParseResult>.

Options (ParseOptions):

  • iniPath: Path to LinuxCNC INI file (required)
  • onProgress: Callback (progress: ParseProgress) => void
  • progressUpdates: Target number of progress updates (default: 40, set to 0 to disable)

Types

Operation Types

TypeDescription
TRAVERSEG0 rapid motion
FEEDG1 linear feed motion
ARCG2/G3 arc motion
PROBEG38.x probe motion
RIGID_TAPG33.1 rigid tapping
DWELLG4 pause
NURBS_G5/G6NURBS curves
UNITS_CHANGEG20/G21
PLANE_CHANGEG17/G18/G19
TOOL_CHANGEM6

(See types.ts for full list including offsets and rotations)

Requirements

  • Linux
  • LinuxCNC installed (provides rs274ngc interpreter library)
  • Node.js 18+

Building from Source

Requires LinuxCNC development headers. Set LINUXCNC_INCLUDE environment variable if headers are not in standard location.

export LINUXCNC_INCLUDE=/path/to/linuxcnc/include
npm install
npm run build

License

GPL-2.0-only

Keywords

linuxcnc

FAQs

Package last updated on 04 Jun 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts