ghutils is a concise collection of utility functions designed to simplify interactions with the GitHub API. Currently stable at version 5.0.2, it has recently undergone a major overhaul, modernizing its codebase. The package now exclusively uses ES Modules (ESM), returns Promises for all asynchronous operations, and leverages the native `fetch` API for HTTP requests. It targets Node.js environments version 20 or higher. ghutils differentiates itself by providing a streamlined, promise-based interface over the GitHub API's various endpoints (GET, POST, PATCH, DELETE) and offers a powerful `lister` function for handling paginated results. It serves as a foundational library for other specialized GitHub interaction packages like `ghissues` and `ghpulls`.
npm install ghutilsVerified import paths — ran on the pinned version, not inferred.
Demonstrates authenticating with a GitHub token, making a single GET request for user data, and listing paginated issues from a repository using `ghget` and `lister`.
Migrate your project to use ES Modules `import` syntax. Ensure your `package.json` has `"type": "module"` or use `.mjs` file extensions. For mixed environments, consider a tool like `cjstoesm` or dynamic `import()` for ESM-only modules.
Update your code to use `await` with `async` functions or `.then().catch()` chains to handle asynchronous operations and retrieve results.
Upgrade your Node.js environment to version 20 or newer. Consider using a version manager like `nvm` to manage multiple Node.js versions.
Ensure your `auth` object is correctly structured and contains a valid GitHub Personal Access Token. Verify the token has the necessary scopes for the API operations you are performing. Consider using `ghauth` for robust token management.
Consult the `lister` API documentation to ensure correct usage of options. For `afterDate`, pass a `Date` object. For query parameters, ensure they match GitHub API specifications (e.g., `per_page` maximum is 100).
Change `const { ghget } = require('ghutils');` to `import { ghget } from 'ghutils';`. Ensure your `package.json` has `"type": "module"` or your file uses the `.mjs` extension.Ensure you are using named import syntax: `import { ghget } from 'ghutils';`. Do not use `import ghget from 'ghutils';` or `import * as ghutils from 'ghutils'; const ghget = ghutils.ghget;` unless you specifically intend to access it from the module object.Double-check the URL against GitHub API documentation. Verify your GitHub Personal Access Token has the necessary scopes (e.g., `repo`, `public_repo`, `user`) for the specific API endpoint being called. Regenerate or update your token if necessary.
Upgrade your Node.js runtime to version 20 or newer. `ghutils` v5+ specifically targets Node.js >= 20, which includes native `fetch`.
No dependency data recorded yet.