Registry / serialization / yang-parser

yang-parser

JSON →
library0.2.1jsnpmunverified

A parser for the YANG data modeling language (RFC 7950) written in CoffeeScript using the Comparse functional parsing library. Current stable version 0.2.1 performs lexical analysis and returns a tree of YANG statements without syntactic or semantic validation. The package has not been updated since 2017 and is considered stable but unmaintained. It is primarily for Node.js usage and depends on Comparse.

npm install yang-parser
INSTALL
IMPORT
SIG · YANG-PARSER
Y
yang-parser
serializationjavascriptv0.2.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parse
import { parse } from 'yang-parser'
const yangParser = require('yang-parser');
The package has no default export; use named import.
parse
const { parse } = require('yang-parser')
CommonJS require with destructuring is also valid.
parse
import { parse } from 'yang-parser'
import parse from 'yang-parser'
Default import is incorrect; the module exports an object with parse.

Parses a YANG module string and logs the resulting JSON tree.

import { parse } from 'yang-parser'; const yangSource = ` module example { namespace "urn:example:system"; prefix sys; organization "Example Inc."; contact "admin@example.com"; description "Example module"; revision 2024-01-01 { description "Initial revision"; } container system { leaf hostname { type string; } } }`; try { const result = parse(yangSource); console.log(JSON.stringify(result, null, 2)); } catch (err) { console.error('Parse error:', err.message); }
Debug
Known issues
deprecatedPackage is unmaintained since 2017; may not support newer YANG RFCs or grammar changes.
fix
Consider migrating to a maintained YANG parser such as yang-parser-js or pyang.
affects: >=0.0.0
gotchaParser only performs lexical analysis; no syntactic or semantic validation. Invalid YANG may parse without error.
fix
Validate output with a separate tool like pyang.
affects: >=0.0.0
breakingDepends on Comparse library which may have breaking changes in newer versions; not pinned.
fix
Install with legacy peer deps if using npm v7+.
affects: >=0.2.0
Errors
Common errors & fixes
Cannot find module 'yang-parser'
Package not installed or module resolution fails.
fix
Run 'npm install yang-parser' in your project directory.
TypeError: yangParser is not a function
Using default import when named import is required.
fix
Use 'import { parse } from 'yang-parser'' instead.
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies
comparserequiredparsing library used internally
Agent activity
21 hits · last 30 days
node
18
OpenAI (training)
1
Resources
yang-parser — npm install yang-parser · libregistry