This package, `npm-config-user-agent-parser`, provides a utility to parse the `process.env.npm_config_user_agent` string, which is set by both npm and Yarn. It extracts structured information including versions for `npm`, `yarn`, and `node`, as well as the operating system `platform` and processor `arch`. The current stable version is 1.0.0, indicating a mature and stable API, and its release cadence is typically infrequent, focusing on stability given its single, well-defined purpose. Key differentiators include its focused scope on this specific environment variable and its ability to normalize the potentially varied user agent strings into a consistent JSON object, simplifying programmatic access to crucial environment details for tooling and scripts.
npm install npm-config-user-agent-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing a sample `npm_config_user_agent` string using the Node API and logging the structured output.
Always check for the existence of `process.env.npm_config_user_agent` before attempting to parse it, and handle cases where it might be undefined or empty.
Implement null checks (e.g., `parsed.npm && parsed.npm.version`) when accessing potentially absent properties from the parsed object to avoid `TypeError`.
For ESM, use `import parser from 'npm-config-user-agent-parser';`. For CommonJS, use `const parser = require('npm-config-user-agent-parser');`.Run `npm install npm-config-user-agent-parser` or `yarn add npm-config-user-agent-parser` in your project directory.
No dependency data recorded yet.