Registry / serialization / iniparser

iniparser

JSON →
library1.0.5jsnpmunverified

This package, `iniparser`, provides a straightforward INI file parser for Node.js environments. Its current stable version is 1.0.5, released in 2012, indicating that the project is no longer actively maintained. It focuses on synchronous and asynchronous parsing of `.ini` files, supporting basic sections and key-value pairs. As an early Node.js utility, it exclusively uses CommonJS modules and does not offer modern features like ESM compatibility, comprehensive configuration options, or built-in TypeScript definitions. Its core functionality includes parsing content from files or strings into a JavaScript object structure. Compared to more recent INI parsers like `@jedmao/ini-parser` or `npm/ini`, `iniparser` lacks ongoing development, broader INI specification support, and a robust community for bug fixes or feature enhancements. It had a brief active period but has been dormant for over a decade.

npm install iniparser
INSTALL
IMPORT
SIG · INIPARSER
I
iniparser
serializationjavascriptv1.0.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

iniparser
const iniparser = require('iniparser');
import iniparser from 'iniparser';
This package only supports CommonJS (`require`). There is no official ESM equivalent and attempting to import it with `import` will fail.
parse
const iniparser = require('iniparser'); iniparser.parse('./config.ini', (err, data) => { /* ... */ });
import { parse } from 'iniparser';
The `parse` method is a property of the main `iniparser` object. It also provides an asynchronous file parsing interface via a callback.
parseSync
const iniparser = require('iniparser'); const config = iniparser.parseSync('./config.ini');
iniparser.parseFile('./config.ini');
For synchronous file parsing, use `parseSync`. The `parseFile` method is not exposed directly for synchronous operations.
parseString
const iniparser = require('iniparser'); const config = iniparser.parseString('foo=bar');
For parsing an INI-formatted string directly, use the `parseString` method.

This quickstart demonstrates how to use `iniparser` for both asynchronous and synchronous parsing of INI files, as well as parsing raw INI strings in a Node.js environment.

const fs = require('fs'); const iniparser = require('iniparser'); const iniContent = ` [database] host = localhost port = 5432 user = admin password = mysecret [server] port = 3000 environment = development `; // Create a dummy INI file fs.writeFileSync('config.ini', iniContent); // 1. Asynchronous file parsing iniparser.parse('./config.ini', (err, data) => { if (err) { console.error('Error parsing config.ini (async):', err); return; } console.log('Async Parsed INI (config.ini):', data); console.log('Database Host:', data.database.host); }); // 2. Synchronous file parsing try { const syncConfig = iniparser.parseSync('./config.ini'); console.log('\nSync Parsed INI (config.ini):', syncConfig); console.log('Server Port:', syncConfig.server.port); } catch (error) { console.error('Error parsing config.ini (sync):', error); } // 3. Parsing a string const stringConfig = iniparser.parseString('[app]\nname=MyApp\nversion=1.0'); console.log('\nParsed INI from string:', stringConfig); console.log('App Name:', stringConfig.app.name); // Clean up dummy file fs.unlinkSync('config.ini');
Debug
Known issues
breakingThe `iniparser` package is abandoned and has not received updates since 2012 (version 1.0.5). It is unlikely to be compatible with modern JavaScript features (e.g., ESM) or secure against recently discovered vulnerabilities. Use at your own risk.
fix
Consider migrating to a actively maintained INI parser library such as `npm/ini`, `@jedmao/ini-parser`, or `js-ini-parser` for better security, features, and compatibility.
affects: >=1.0.5
gotchaThis package is strictly CommonJS (CJS). Attempting to use `import` statements in an ES Module context (e.g., in a Node.js project with `"type": "module"` in `package.json` or in browser environments) will result in a runtime error.
fix
Ensure your project uses CommonJS (`require`) for this package or transpile your code if you must use it in an ESM project (not recommended). For new projects, prefer ESM-compatible alternatives.
affects: >=1.0.0
gotchaThe parser's handling of INI file syntax might be less robust compared to modern parsers. Specific edge cases like whitespace around section names or key-value assignments, different comment styles, or complex values might lead to unexpected parsing results or errors.
fix
Thoroughly test `iniparser` with your specific INI file formats. If encountering issues, consider a more configurable and actively maintained INI parser that explicitly handles such edge cases.
affects: >=1.0.0
gotchaThe library does not provide TypeScript type definitions. Using it in a TypeScript project will require creating custom declaration files (`.d.ts`) or relying on `any` types, reducing type safety.
fix
Manually create a `iniparser.d.ts` file or migrate to a library with built-in TypeScript support.
affects: >=1.0.0
Errors
Common errors & fixes
ReferenceError: require is not defined
Attempting to use `require()` in an ES Module (ESM) context, which is not supported natively in ESM files.
fix
Change your file to use CommonJS by ensuring it's not an ESM module (e.g., remove `"type": "module"` from `package.json` or rename `.mjs` files to `.js`), or rewrite the code to use an ESM-compatible INI parser.
TypeError: Cannot read properties of undefined (reading 'someKey')
This typically occurs when a section or key you are trying to access does not exist in the parsed INI data, or the INI file itself is malformed and couldn't be fully parsed.
fix
Verify the structure of your INI file and ensure the section and key names match exactly (case-sensitive access may be a factor, although `iniparser` generally normalizes to lowercase keys). Add checks for `undefined` before accessing nested properties (e.g., `data.section?.key`).
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
iniparser — npm install iniparser · libregistry