Registry / serialization / env-parser

env-parser

JSON →
library1.0.1jsnpmunverified

env-parser (digitalsadhu/env-parser) is a streaming transform module designed to parse individual `key=value` pairs from a stream and emit JavaScript objects. It processes data by splitting on the first equals sign (`=`) and automatically removes quotation marks from values if present. As of version 1.0.1, last published in June 2015, this package appears to be unmaintained. Its primary use case is for integrating into Node.js stream pipelines where environment variable-like strings are being processed sequentially, rather than for parsing complete `.env` files. There are no indications of active development or a release cadence, and newer, more comprehensive environment variable parsing libraries are widely available.

npm install env-parser
INSTALL
IMPORT
SIG · ENV-PARSER
E
env-parser
serializationjavascriptv1.0.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.

envParser
const envParser = require('env-parser'); const parserInstance = envParser();
import envParser from 'env-parser'; import { envParser } from 'env-parser';
This package is a CommonJS module and exports a factory function. It does not support ES Modules directly. The exported function must be called to create a stream instance.
Transform Stream
const { Transform } = require('stream'); const envParser = require('env-parser')();
import { Transform } from 'stream';
The `env-parser` module returns a Node.js Transform stream instance. It's intended to be used within stream pipelines.

Demonstrates how to use `env-parser` as a Node.js Transform stream, feeding it simulated environment variable strings and listening for the parsed objects.

const { Readable } = require('stream'); const envParser = require('env-parser')(); // Create a readable stream to feed data into the parser const inputStream = new Readable({ read() { this.push('ENV_KEY_1="some value with spaces"\n'); this.push('ENV_KEY_2=another_value\n'); this.push('PATH_VAR=/usr/local/bin:/usr/bin\n'); this.push(null); // No more data } }); envParser.on('data', function (envObject) { console.log('Parsed:', envObject); // Expected output example: // { key: 'ENV_KEY_1', value: 'some value with spaces' } // { key: 'ENV_KEY_2', value: 'another_value' } // { key: 'PATH_VAR', value: '/usr/local/bin:/usr/bin' } }); envParser.on('end', () => { console.log('Parsing finished.'); }); envParser.on('error', (err) => { console.error('Parser error:', err.message); }); // Pipe the input stream to the envParser transform stream inputStream.pipe(envParser);
Debug
Known issues
breakingThis package is explicitly a CommonJS module and does not natively support ES Module `import` syntax. Attempting to use `import` will result in errors.
fix
Use CommonJS `require()` syntax: `const envParser = require('env-parser');`
affects: >=1.0.0
deprecatedThe `env-parser` package (digitalsadhu/env-parser) has not been updated since June 2015 and is considered abandoned. It may contain unpatched vulnerabilities or incompatibilities with modern Node.js versions.
fix
Consider migrating to actively maintained alternatives like `dotenv` for `.env` file parsing or a more robust streaming parser if your use case specifically requires line-by-line stream processing.
affects: >=1.0.0
gotchaThis package is a basic streaming parser for *individual* `key=value` lines. It does not handle multi-line values, variable interpolation, comments (other than treating '#' as part of a value if not quoted), or full `.env` file semantics (like parsing an entire file). Each `write()` call or piped chunk is treated as a potential `key=value` pair.
fix
Ensure input data is formatted as single `KEY=VALUE` lines. For more complex `.env` parsing, use a dedicated library like `dotenv` or `envfile`. If comments are desired, they must be stripped from the input stream *before* passing to `env-parser`.
affects: >=1.0.0
gotchaThe `env-parser` module exports a *factory function* which must be called to create a stream instance (`require('env-parser')()`). Forgetting the `()` will result in `TypeError: envParser is not a function` when attempting to use it as a stream.
fix
Always invoke the required module as a function: `const parser = require('env-parser')();`
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: envParser is not a function
The `env-parser` module exports a factory function, not a stream instance directly. You attempted to use the imported module directly as a stream without calling it.
fix
Call the required module to get a stream instance: `const parser = require('env-parser')();`
SyntaxError: Unexpected token 'export' / Cannot use import statement outside a module
You are attempting to use ES Module `import` syntax with a CommonJS-only package, or your Node.js environment is not configured for ESM for this file.
fix
Use CommonJS `require()` syntax: `const envParser = require('env-parser');`. If you must use ESM, consider a CommonJS wrapper or a different, actively maintained package with ESM support.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
env-parser — npm install env-parser · libregistry