Registry / http-networking / argv-parser

argv-parser

JSON →
library0.1.4jsnpmunverified

Argv-parser is an extremely lightweight Node.js module designed for basic parsing of `process.argv`. Published in 2013, its current stable version is 0.1.4. Unlike more comprehensive command-line argument libraries such as `yargs` or `commander.js`, `argv-parser` intentionally avoids features like option registration, automatic help message generation, or advanced type coercion, focusing solely on extracting key-value pairs and raw arguments. Its design philosophy prioritizes simplicity and a minimal footprint, directly returning parsed objects, warnings, and errors. Due to its age and lack of updates, it is considered abandoned and is not suitable for new projects requiring active maintenance or modern JavaScript features.

npm install argv-parser
INSTALL
IMPORT
SIG · ARGV-PARSER
A
argv-parser
http-networkingjavascriptv0.1.4
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.

parser
const parser = require('argv-parser');
import { parser } from 'argv-parser';
This package predates widespread ESM support in Node.js and is exclusively CommonJS. Direct named imports are not supported.
parse method
const { parse } = require('argv-parser').parser;
const { parse } = require('argv-parser');
The package exports a 'parser' object, not a top-level 'parse' function. You must access `parser.parse`.

Demonstrates how to import the `argv-parser` module, define parsing rules, and use the `parse` method to extract command-line arguments into a structured object.

const parser = require('argv-parser'); // Simulate process.argv for demonstration const simulatedArgv = [ 'node', 'script.js', '--name=Alice', '-v', '--env=production', '--port', '3000', 'input.txt', '--flag' ]; const options = { rules: { // 'rules' is an extended nopt rules object 'name': String, 'v': Boolean, // Short form for verbose 'env': String, 'port': Number, 'flag': Boolean }, offset: 2 // Skip 'node' and 'script.js' }; const result = parser.parse(simulatedArgv, options); console.log('Parsed Arguments:', result.parsed); console.log('Warnings:', result.warnings); console.log('Errors:', result.errors); /* Example Output: { name: 'Alice', v: true, env: 'production', port: 3000, flag: true, argv: [ 'input.txt' ] } */
Debug
Known issues
breakingThe `argv-parser` package is completely abandoned and has not received updates since 2013. It is not compatible with modern JavaScript module systems (ESM) and may have unpatched vulnerabilities or unexpected behavior with newer Node.js versions.
fix
Migrate to a actively maintained command-line argument parser library like `yargs`, `commander.js`, or `minimist` for new projects. For legacy projects, consider vendoring the code or accepting the risks.
affects: 0.1.4
gotchaThis library does not perform automatic type conversion or validation beyond basic `String`, `Boolean`, and `Number` types if specified in `rules`. Complex types or custom validation logic must be implemented manually on the `parsed` object.
fix
Post-process the `result.parsed` object to apply additional type conversions or validations as needed, or use a more robust parsing library that offers these features natively.
affects: 0.1.4
gotchaThe library returns `warnings` and `errors` objects, but does not inherently stop execution or throw exceptions for parsing issues. It's up to the developer to inspect these objects and handle them appropriately.
fix
Always check `result.warnings` and `result.errors` after calling `parser.parse()` and implement custom error handling or logging based on their content.
affects: 0.1.4
gotchaThere is no built-in `--help` output generation or option description functionality. All argument usage documentation needs to be created and maintained separately.
fix
If help output is required, manually construct and display it based on your application's expected arguments. Consider a different library if this is a core requirement.
affects: 0.1.4
Errors
Common errors & fixes
TypeError: require(...) is not a function
Attempting to use ES Modules (import/export) syntax with this CommonJS-only package.
fix
Ensure your project uses CommonJS (`require()`) or transpile your code to CommonJS. Example: `const parser = require('argv-parser');`
TypeError: parser.parse is not a function
Incorrectly destructuring the module's export. The package exports an object with a `parser` property, not a direct `parse` function.
fix
Access the `parse` method via the `parser` object: `const { parse } = require('argv-parser').parser;` or `const parserModule = require('argv-parser'); const result = parserModule.parser.parse(...);`
Error: Cannot find module 'argv-parser'
The package is not installed or the Node.js module resolution path is incorrect.
fix
Run `npm install argv-parser` to install the package.
Upgrade
Version history
0.1.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
24 hits · last 30 days
node
20
OpenAI (training)
1
Resources