{"id":12829,"library":"argv-parser","title":"Simple Node.js Argv Parser","description":"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.","status":"abandoned","version":"0.1.4","language":"javascript","source_language":"en","source_url":"git://github.com/kaelzhang/argv-parser","tags":["javascript","argv","parser","argument-vector","cleaner","simple"],"install":[{"cmd":"npm install argv-parser","lang":"bash","label":"npm"},{"cmd":"yarn add argv-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add argv-parser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package predates widespread ESM support in Node.js and is exclusively CommonJS. Direct named imports are not supported.","wrong":"import { parser } from 'argv-parser';","symbol":"parser","correct":"const parser = require('argv-parser');"},{"note":"The package exports a 'parser' object, not a top-level 'parse' function. You must access `parser.parse`.","wrong":"const { parse } = require('argv-parser');","symbol":"parse method","correct":"const { parse } = require('argv-parser').parser;"}],"quickstart":{"code":"const parser = require('argv-parser');\n\n// Simulate process.argv for demonstration\nconst simulatedArgv = [\n  'node',\n  'script.js',\n  '--name=Alice',\n  '-v',\n  '--env=production',\n  '--port', '3000',\n  'input.txt',\n  '--flag'\n];\n\nconst options = {\n  rules: { // 'rules' is an extended nopt rules object\n    'name': String,\n    'v': Boolean, // Short form for verbose\n    'env': String,\n    'port': Number,\n    'flag': Boolean\n  },\n  offset: 2 // Skip 'node' and 'script.js'\n};\n\nconst result = parser.parse(simulatedArgv, options);\n\nconsole.log('Parsed Arguments:', result.parsed);\nconsole.log('Warnings:', result.warnings);\nconsole.log('Errors:', result.errors);\n\n/* Example Output:\n{\n  name: 'Alice',\n  v: true,\n  env: 'production',\n  port: 3000,\n  flag: true,\n  argv: [\n    'input.txt'\n  ]\n}\n*/","lang":"javascript","description":"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."},"warnings":[{"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.","message":"The `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.","severity":"breaking","affected_versions":"0.1.4"},{"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.","message":"This 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.","severity":"gotcha","affected_versions":"0.1.4"},{"fix":"Always check `result.warnings` and `result.errors` after calling `parser.parse()` and implement custom error handling or logging based on their content.","message":"The 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.","severity":"gotcha","affected_versions":"0.1.4"},{"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.","message":"There is no built-in `--help` output generation or option description functionality. All argument usage documentation needs to be created and maintained separately.","severity":"gotcha","affected_versions":"0.1.4"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure your project uses CommonJS (`require()`) or transpile your code to CommonJS. Example: `const parser = require('argv-parser');`","cause":"Attempting to use ES Modules (import/export) syntax with this CommonJS-only package.","error":"TypeError: require(...) is not a 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(...);`","cause":"Incorrectly destructuring the module's export. The package exports an object with a `parser` property, not a direct `parse` function.","error":"TypeError: parser.parse is not a function"},{"fix":"Run `npm install argv-parser` to install the package.","cause":"The package is not installed or the Node.js module resolution path is incorrect.","error":"Error: Cannot find module 'argv-parser'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null}