{"id":15150,"library":"node-modules","title":"Node Modules CLI and Library","description":"The `node-modules` package provides both a command-line interface (CLI) tool and a Node.js module for searching `node-modules.com`. Its primary functionality involves querying the site for packages, with an option to personalize results based on GitHub follows or stars. The current stable version is 1.0.1. Given its age and reliance on `node-modules.com` (which is no longer a primary source for package discovery, superseded by npmjs.com), the package has likely ceased active development. It does not appear to follow a regular release cadence and is designed for an ecosystem context that has largely evolved, making its key differentiator (integration with `node-modules.com`) less relevant today.","status":"abandoned","version":"1.0.1","language":"javascript","source_language":"en","source_url":"git://github.com/mafintosh/node-modules-cli","tags":["javascript","node-modules.com","cli","search","node","modules"],"install":[{"cmd":"npm install node-modules","lang":"bash","label":"npm"},{"cmd":"yarn add node-modules","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-modules","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only, as indicated by its `require` usage in examples and its age (version 1.0.1). Attempting to use ES Modules `import` will result in a `ReferenceError` or similar module resolution error in most modern Node.js environments without a CommonJS wrapper.","wrong":"import search from 'node-modules';","symbol":"search","correct":"const search = require('node-modules');"},{"note":"While the package offers CLI functionality, the main module export is a search function. Direct programmatic access to the CLI logic (e.g., parsing arguments, invoking commands) is not explicitly exposed via named exports in the primary `node-modules` entry point. Users typically interact with the CLI via `node-modules <command>` in the terminal.","wrong":"import { NodeModulesCLI } from 'node-modules';","symbol":"NodeModulesCLI","correct":"require('node-modules/cli'); // or similar for programmatic CLI access"},{"note":"The `search` function returns a readable stream directly, not an object with a `stream` property. The common pattern is to call `search()` and then attach event listeners to the returned stream for 'data' and 'end'.","wrong":"const { stream } = require('node-modules');","symbol":"stream","correct":"search('query').on('data', handler);"}],"quickstart":{"code":"const search = require('node-modules');\n\n// Search for 'test framework' packages\n// Replace 'mafintosh' with your GitHub username if personalizing.\nconst stream = search('test framework', { username: 'mafintosh' });\n\nconsole.log('Searching for packages...');\n\nstream.on('data', function(result) {\n  // result is an object containing package information\n  console.log(`- ${result.name} (v${result.version || 'N/A'}): ${result.description || 'No description'}`);\n});\n\nstream.on('end', function() {\n  console.log('--- Search complete. No more results. ---');\n});\n\nstream.on('error', function(err) {\n  console.error('An error occurred during search:', err.message);\n  if (err.message.includes('ECONNREFUSED') || err.message.includes('ENOTFOUND')) {\n    console.error('This might be due to node-modules.com being unavailable or unreachable.');\n  }\n});","lang":"javascript","description":"Demonstrates how to use the `node-modules` library to perform a search and process the streamed results, including basic error handling."},"warnings":[{"fix":"There is no direct fix for the unavailability of the backend service. Users should consider alternative package search tools like `npm search` or directly browsing `npmjs.com`.","message":"The package relies on the `node-modules.com` website for search functionality. As of current information, this website is either defunct or no longer actively maintained, making the core functionality of this package effectively broken.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"For use in CJS environments, use `const search = require('node-modules');`. In ESM environments, a dynamic `import()` or a CJS wrapper might be necessary: `const search = await import('node-modules').then(m => m.default || m);` (though `m.default` is unlikely for this package, it's good practice for others).","message":"The `node-modules` package is written exclusively in CommonJS (CJS) and does not natively support ES Modules (ESM) syntax. Attempting to `import` it in an ESM context will lead to module resolution errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Due to its abandoned status, it's recommended to avoid using this package for new projects. For existing projects, perform a security audit of its dependencies (e.g., `npm audit`) and consider migrating to actively maintained alternatives.","message":"The package has not been updated since 2014, meaning it may contain outdated dependencies or security vulnerabilities, and is unlikely to receive patches for newly discovered issues.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Install the package globally using `npm install -g node-modules`.","cause":"The `node-modules` CLI tool was not installed globally or is not in your system's PATH.","error":"node-modules: command not found"},{"fix":"Use `const search = await import('node-modules');` or convert your file to CommonJS. However, given the package's design, using it in modern ESM projects is generally discouraged.","cause":"Attempting to use `require('node-modules')` inside an ES Module (ESM) file (e.g., a `.mjs` file or a `.js` file in a `\"type\": \"module\"` project).","error":"ReferenceError: require is not defined in ES module scope"},{"fix":"This issue is inherent to the dependency on a potentially defunct external service. There is no code-level fix for this specific package. You must use alternative package discovery methods.","cause":"The `node-modules` package tried to connect to `node-modules.com` but the connection was refused. This typically indicates the server is offline, unreachable, or has been shut down.","error":"Error: connect ECONNREFUSED <ip-address>:<port>"}],"ecosystem":"npm"}