netrc-parser is a Node.js library designed to parse, load, and save `.netrc` files, which are traditionally used by FTP clients and other utilities to store login credentials for remote machines. The package provides both synchronous and asynchronous APIs for file operations and machine access. Currently at version 3.1.6, the library appears to be in a maintenance phase with its last significant update several years ago (circa 2019), indicating a stable API. It ships with TypeScript type definitions, making it suitable for modern TypeScript projects, and differentiates itself by offering a straightforward interface for managing machine entries programmatically. While there are other `netrc` parsing solutions available, this package focuses specifically on the Node.js ecosystem, handling common patterns like `login`, `password`, and `account` fields.
npm install netrc-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates loading, accessing, modifying, and saving `.netrc` entries, including basic error handling for file operations.
Always ensure your `~/.netrc` file has strict permissions, typically `chmod 600 ~/.netrc` on Unix-like systems, making it readable and writable only by the file owner.
For CommonJS, use `const Netrc = require('netrc-parser').default;`. For ESM/TypeScript, use `import Netrc from 'netrc-parser';`.Adhere strictly to the `.netrc` file format: `machine HOST login USER password PASSWORD account ACCOUNT`. Ensure comments start with `#` at the beginning of a line. Test with a minimal `.netrc` file if encountering parsing issues.
For CommonJS: `const Netrc = require('netrc-parser').default;`. For ESM/TypeScript: `import Netrc from 'netrc-parser';` or `import { default as Netrc } from 'netrc-parser';`.Adjust the file permissions for `~/.netrc` to be readable and writable only by the owner: `chmod 600 ~/.netrc`. Also, ensure the parent directory has appropriate permissions.
Inspect your `~/.netrc` file for syntax errors. Ensure each `machine` block is correctly formatted with `login`, `password`, and `account` (if present) on separate lines or correctly space-separated, and that no unexpected characters or incomplete entries exist.
No dependency data recorded yet.