This library provides a robust and flexible option parsing solution for Node.js command-line interfaces. It is famously used by npm itself to handle its complex array of command-line arguments and configuration. `nopt` supports defining various option types (String, Number, Boolean, path, url, Date, Stream), shorthands for brevity, and mechanisms for handling unknown options. It maintains a consistent release cadence, with major versions frequently aligning with Node.js LTS cycles. The current stable version, `9.0.0`, requires Node `^20.17.0 || >=22.9.0`. Its key differentiators include strong type definition capabilities, automatic path resolution, and a battle-tested core proven by its integration into the npm CLI.
npm install noptVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic option parsing using `nopt`, defining known options with types and shorthands, and processing `process.argv` to extract command-line arguments into a structured object.
Ensure your project's Node.js environment meets the `^20.17.0 || >=22.9.0` requirement. Upgrade Node.js if necessary.
Verify your Node.js version is `^18.17.0 || >=20.5.0`. Older versions will no longer be supported.
Update your Node.js runtime to one within the `^14.17.0 || ^16.13.0 || >=18.0.0` range.
If upgrading from `nopt@5.x` or older, ensure your Node.js version is at least 12.x LTS or 14.x LTS.
Upgrade to `nopt@6.0.0` or newer to avoid deprecated API usage warnings.
Ensure 'nopt' is installed as a dependency: `npm install nopt` or `yarn add nopt`. Verify your `NODE_PATH` if using custom module paths.
For ESM, use `import nopt from 'nopt';`. For CommonJS, use `const nopt = require('nopt');`. If the issue persists, try deleting `node_modules` and `package-lock.json` and reinstalling dependencies.Upgrade your Node.js environment to a version compatible with `nopt`'s requirements (e.g., `^20.17.0 || >=22.9.0` for v9.0.0). Consider using `nvm` or `volta` to manage Node.js versions.
No dependency data recorded yet.