{"library":"pip-requirements-js","title":"Pip Requirements File Parser for JavaScript","description":"pip-requirements-js is a pure JavaScript and TypeScript library designed to robustly parse `requirements.txt`, `constraints.txt`, and `requirements.in` files, strictly adhering to pip's documentation on the requirements file format and PEP 508 for dependency specification. The current stable version is 1.0.3, released on March 9, 2026. The project shows an active development cadence, with several releases in late 2025 and early 2026. Its key differentiator is the use of the Ohm.js parser generator, ensuring high fidelity to Python's pip parsing logic, including complex environment markers and file inclusions. It offers both 'full' and 'loose' parsing modes, with options to include source location information for advanced use cases like editor tooling.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install pip-requirements-js"],"cli":null},"imports":["import { parsePipRequirementsFile } from 'pip-requirements-js';","import { parsePipRequirementsLine } from 'pip-requirements-js';","import type { Requirement } from 'pip-requirements-js';","import { RequirementsSyntaxError } from 'pip-requirements-js';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { parsePipRequirementsFile, RequirementsSyntaxError } from 'pip-requirements-js';\nimport type { Requirement, WithLocation } from 'pip-requirements-js';\n\nconst requirementsFileContent = `\n# My project dependencies\nDjango==4.2.0 ; python_version < '3.12'\nrequests>=2.28.0,<3.0.0 # HTTP library\n-r base.txt\nproject-core @ file:///local_libs/project_core-1.0-py3-none-any.whl\n`;\n\ntry {\n  const requirements: Requirement[] = parsePipRequirementsFile(requirementsFileContent);\n  console.log('Parsed requirements (full):', requirements);\n\n  const requirementsWithLocations: WithLocation<Requirement>[] = parsePipRequirementsFile(\n    requirementsFileContent,\n    { includeLocations: true }\n  );\n  console.log('Parsed requirements with locations:', requirementsWithLocations[0].location);\n} catch (error) {\n  if (error instanceof RequirementsSyntaxError) {\n    console.error('Syntax error in requirements file:', error.message);\n  } else {\n    console.error('An unexpected error occurred:', error);\n  }\n}\n","lang":"typescript","description":"Demonstrates parsing a multi-line `requirements.txt` string in both standard and location-inclusive modes, including basic error handling for syntax issues.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}