Registry / argsparser

argsparser

JSON →
library0.0.7jsnpmunverified

argsparser is an extremely tiny command-line arguments parser for Node.js, last published as version 0.0.7 over a decade ago. It operates by converting an array of arguments (typically `process.argv`) into a key-value object based on simple parsing rules. Keys are identified as the first element or elements prefixed by `-` or `--`. Subsequent elements become the key's value; if multiple values follow, they form an array, and if no value, the key's value is `true`. Its primary differentiator was its minimalistic footprint and simple parsing logic. Due to its age, lack of maintenance, and reliance on very old Node.js versions (specifically `>=0.2.0`), it is not suitable for modern projects and should be considered entirely abandoned. Modern alternatives like `commander`, `yargs`, or `minimist` offer robust and actively maintained solutions for CLI parsing.

npm install argsparser
INSTALL
IMPORT
SIG · ARGSPARSER
A
argsparser
javascriptv0.0.7
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.

parse
const argsparser = require('argsparser'); const args = argsparser.parse();
import { parse } from 'argsparser';
This package is strictly CommonJS. ES Module `import` syntax is not supported. Attempting to `import` will result in a runtime error in modern Node.js environments unless explicitly transpiled or using dynamic import() in an async context, which is overly complex for this package.
argsparser (default)
const argsparser = require('argsparser');
import argsparser from 'argsparser';
The package exports a single function-like object; there is no named export. Direct `require('argsparser')` retrieves the main module object which contains the `parse` method.

Demonstrates parsing `process.argv` by default and parsing a custom array of arguments, illustrating how flags, values, and multi-value options are handled.

const argsparser = require('argsparser'); // Example 1: Parses process.argv by default // Assuming script run with: node script.js -a test --b another const defaultArgs = argsparser.parse(); console.log('Default (process.argv) parse result:', defaultArgs); // Expected output (approx): { node: '/path/to/node', 'script.js': '/path/to/script.js', '-a': 'test', '--b': 'another' } // Example 2: Passing a custom array of arguments const customArgs = argsparser.parse(['-x', 'value1', 'value2', '--flag']); console.log('Custom array parse result:', customArgs); // Expected output: { '-x': ['value1', 'value2'], '--flag': true } // Example 3: No arguments (empty array) const emptyArgs = argsparser.parse([]); console.log('Empty array parse result:', emptyArgs); // Expected output: {}
Debug
Known issues
breakingThis package is entirely unmaintained, with its last publish over 10 years ago. It has not received any updates to support modern Node.js versions, security patches, or bug fixes. Using it in production or any modern environment is highly discouraged and poses significant security and compatibility risks.
fix
Migrate to a actively maintained CLI arguments parser like `commander`, `yargs`, or `minimist`.
affects: 0.0.7
breakingThe package explicitly targets Node.js `>=0.2.0`, an extremely old version released in 2010. Modern Node.js versions have significant breaking changes, particularly regarding module systems (CommonJS vs. ES Modules) and core APIs. This package will likely not function correctly or at all in current Node.js runtimes without extensive compatibility layers.
fix
Replace `argsparser` with a modern, actively maintained CLI parsing library. If forced to use, ensure your Node.js environment is configured to run legacy CommonJS modules and be prepared for potential runtime errors.
affects: 0.0.7
gotchaThe parsing logic is very simple: it treats the first element as a key, and then elements prefixed with '-' or '--' as new keys. All subsequent elements are values until another key is found. If no value follows a key, it becomes `true`. This heuristic-based approach can lead to unexpected parsing results for complex or non-standard argument patterns compared to more feature-rich parsers.
fix
Thoroughly test argument parsing for all expected and edge-case inputs if using this library. For more robust and configurable parsing, consider alternatives like `commander` or `yargs`.
affects: 0.0.7
Errors
Common errors & fixes
TypeError: require is not a function
Attempting to use `require('argsparser')` in an ES Module context (`.mjs` file or `"type": "module"` in `package.json`). `argsparser` is a CommonJS module.
fix
If you must use this package, ensure your file is a CommonJS module (`.js` without `"type": "module"`) or use dynamic `import()` within an `async` function. For new projects, use modern ES Module compatible CLI parsers.
Error: Cannot find module 'argsparser'
The package is not installed or `npm install` failed. Alternatively, there might be caching issues with `node_modules`.
fix
Run `npm install argsparser` to ensure the package is correctly installed. If issues persist, try `rm -rf node_modules && npm install`.
Upgrade
Version history
0.0.7latest on npm
Audit
Dependencies

No dependency data recorded yet.

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