node-fetch-cookies is a wrapper around the popular `node-fetch` library, specifically designed to add robust support for HTTP cookie management in Node.js environments. It enables developers to easily handle cookie-jars, allowing for persistent session management across multiple requests. The library supports both in-memory cookie storage and file-based persistence using JSON files, minimizing disk I/O by only saving when explicitly instructed. As of version 2.1.1, the project is actively maintained, addressing recent bug fixes related to redirect handling and cookie attribute parsing. It primarily targets modern Node.js environments (>=14.13.0) and leverages ES Modules for its primary usage patterns. Its key differentiators include simplified cookie persistence and re-exporting core `node-fetch` components, providing a familiar API while adding essential cookie functionality.
npm install node-fetch-cookiesVerified import paths — ran on the pinned version, not inferred.
Demonstrates initializing a CookieJar with file persistence, loading existing cookies, making multiple requests with automatic cookie handling, and saving updated cookies to disk.
Upgrade to version `2.1.1` or newer. If upgrading is not possible, ensure your application does not rely on automatic `content-length` header removal during redirect following.
Upgrade to version `2.1.1` or newer to ensure correct cookie header handling during redirects.
Upgrade to version `2.1.0` or newer for corrected and more robust HTTP redirect handling.
For new projects, prefer using ESM (`import`). If using in a CommonJS project, ensure your build setup correctly handles ESM dependencies or consider explicitly importing `node-fetch-cookies` using dynamic import (`await import('node-fetch-cookies')`).Upgrade `node-fetch-cookies` to version `2.1.1` or newer.
Update `node-fetch-cookies` to version `2.1.1` or higher.
Upgrade `node-fetch-cookies` to version `2.1.0` or newer.
Convert your project or relevant file to use ES Modules (`type: "module"` in `package.json`, `.mjs` extension) and use `import { fetch, CookieJar } from 'node-fetch-cookies';`. Alternatively, use dynamic import: `const { fetch, CookieJar } = await import('node-fetch-cookies');`.