Registry / serialization / properties

properties

JSON →
library0.6.1jsnpmunverified

The `properties` package provides a comprehensive parser and stringifier for Java-style `.properties` files, including support for extended features such as INI-like sections, variable expansion (including references to environment variables), dot-separated namespaces, and file import directives. The current stable version is 1.2.1. Although the README once implied active development, the package's last update was over nine years ago, and its `engines.node` requirement (>=0.10) indicates it targets very old Node.js environments, suggesting it is now abandoned. It distinguishes itself by not only adhering to the core Java `.properties` specification but also by offering powerful, opt-in enhancements that allow for highly structured and dynamic configuration management, going beyond basic key-value pair parsing.

npm install properties
INSTALL
IMPORT
SIG · PROPERTIES
P
properties
serializationjavascriptv0.6.1
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.

properties
const properties = require('properties');
import properties from 'properties'; import { parse } from 'properties';
This package is CommonJS-only and does not support ES module `import` syntax.
parse
const properties = require('properties'); properties.parse(data, options, callback);
import { parse } from 'properties'; parse(data, options, callback);
The `parse` function is accessed as a method of the default CommonJS export.
stringify
const properties = require('properties'); properties.stringify(obj, options, callback);
import { stringify } from 'properties'; stringify(obj, options, callback);
The `stringify` function is accessed as a method of the default CommonJS export.

Demonstrates parsing a `.properties` file from a file path, including support for INI-style sections and logging the resulting JavaScript object.

const properties = require('properties'); const fs = require('fs'); const path = require('path'); const filePath = path.join(__dirname, 'config.properties'); const fileContent = `# Application Configuration app_name = MyWebApp [web] hostname = 127.0.0.1 port = 3000 [db] hostname = localhost port = 5432 user = admin `; // Create a dummy config file for parsing fs.writeFileSync(filePath, fileContent); properties.parse(filePath, { path: true, sections: true, variables: true }, function (error, obj) { if (error) { console.error('Error parsing properties:', error); return; } console.log('Parsed Configuration:'); console.log(obj); // Expected output will include nested objects for sections // { app_name: 'MyWebApp', web: { hostname: '127.0.0.1', port: 3000 }, db: { hostname: 'localhost', port: 5432, user: 'admin' } } // Clean up the dummy file fs.unlinkSync(filePath); });
Debug
Known issues
gotchaMany advanced features like INI sections, variable expansion, and namespaces are opt-in. They must be explicitly enabled via options in the `parse` or `stringify` methods, as they are not active by default.
fix
Always explicitly pass an options object to `properties.parse()` or `properties.stringify()`, for example: `{ sections: true, variables: true, namespaces: true }` to enable desired functionalities.
affects: >=1.0.0
breakingThis package is effectively abandoned (last updated 9+ years ago) and targets very old Node.js versions (>=0.10). It may not function correctly, have security vulnerabilities, or integrate well with modern Node.js environments (e.g., ESM-only projects, current dependency management, newer `fs` module behaviors).
fix
Thoroughly test compatibility in your specific environment before using in production. For new projects, consider using a more actively maintained `.properties` or general configuration parsing library that supports modern JavaScript ecosystems.
affects: >=1.0.0
gotchaUsing the `path: true` option or the `include` feature with untrusted file paths can introduce directory traversal vulnerabilities or arbitrary file read exploits, as it directly accesses the file system based on input.
fix
Rigorously sanitize and validate all input file paths when using `path: true` or the `include` option with user-supplied data to prevent malicious file system access.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: properties.parse is not a function
This error typically occurs when attempting to use ES module `import` syntax (e.g., `import { parse } from 'properties'`) or incorrect destructuring in a CommonJS environment.
fix
Use the CommonJS `require` syntax: `const properties = require('properties');` and then access the function as `properties.parse(data, options, callback);`.
Error: ENOENT: no such file or directory, open 'your/file/path.properties'
When `path: true` is provided in the options, the first argument to `properties.parse` is interpreted as a file path. This error indicates that the specified file does not exist or the application lacks the necessary permissions to read it.
fix
Ensure the file path provided to `properties.parse` is correct and absolute or relative to the current working directory. Also, verify that the Node.js process has read permissions for the specified file.
SyntaxError: Unexpected token { (or similar parsing errors)
The input `.properties` file contains syntax that is malformed or uses features (like INI sections, variables, or namespaces) that are not enabled via the options object passed to `properties.parse`.
fix
Review your `.properties` file for syntax errors. If you are using advanced features, ensure the corresponding options (e.g., `sections: true`, `variables: true`, `namespaces: true`) are explicitly set in the options object for `properties.parse`.
Upgrade
Version history
0.6.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
Resources
properties — npm install properties · libregistry