npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

hallucination-finder

v1.0.1

Published

Find AI-hallucinated packages in your codebase. Scan imports that reference npm packages that don't actually exist.

Downloads

25

Readme

🔍 hallucination-finder

Find AI-hallucinated packages hiding in your codebase.

"You vibe coded it. But can you own it?"

AI coding assistants (ChatGPT, Copilot, Claude, etc.) sometimes hallucinate npm packages that don't actually exist. These phantom imports slip into your codebase, silently breaking builds or — worse — opening the door to dependency confusion attacks where bad actors register the hallucinated package name with malicious code.

hallucination-finder scans your JavaScript/TypeScript project, checks every imported package against the npm registry, and tells you which ones are completely made up.


⚡ Quick Start

# Scan current directory
npx hallucination-finder

# Scan a specific project
npx hallucination-finder ./my-project

# Get JSON output (great for CI)
npx hallucination-finder --json

# Save report to file
npx hallucination-finder --output report.json

📦 Install

# Global install
npm install -g hallucination-finder

# Or as a dev dependency
npm install --save-dev hallucination-finder

🔎 What It Does

  1. Scans all .js, .jsx, .ts, .tsx, .mjs, .cjs files in your project
  2. Extracts every import and require() statement
  3. Filters out local imports, Node.js built-ins, and relative paths
  4. Checks each package against the npm registry
  5. Reports which packages are hallucinated (don't exist)

🚨 Example Output

 🚨 Found 3 hallucinated packages!

  1. react-smooth-carousel ← does NOT exist on npm
     📍 src/components/Hero.jsx:3
        import { Carousel } from 'react-smooth-carousel'

  2. express-auth-helper ← does NOT exist on npm
     📍 src/middleware/auth.js:1
        const auth = require('express-auth-helper')

  3. @utils/smart-cache ← does NOT exist on npm
     📍 src/lib/cache.ts:2
        import { SmartCache } from '@utils/smart-cache'

 ⚠️  What to do:
    These packages were likely hallucinated by an AI coding assistant.
    Check if a real alternative exists, or if the code needs rewriting.

🤖 Why This Matters

With AI-assisted coding becoming the norm, hallucinated packages are a real and growing problem:

  • Build failures: Your code imports something that doesn't exist, and nobody notices until deploy day
  • Security risk: Attackers can register hallucinated package names and inject malicious code (supply chain attacks)
  • Time wasted: Debugging "module not found" errors from AI-generated code
  • False confidence: Your code looks complete but references phantom dependencies

🛠️ Use in CI/CD

hallucination-finder exits with code 1 if hallucinations are found, making it perfect for CI pipelines:

# GitHub Actions
- name: Check for hallucinated packages
  run: npx hallucination-finder .
# GitLab CI
hallucination-check:
  script:
    - npx hallucination-finder .

📡 Programmatic API

const { findHallucinations } = require('hallucination-finder');

const results = await findHallucinations('./my-project', {
  concurrency: 8,          // parallel registry checks
  onProgress: (current, total, name) => {
    console.log(`Checking ${current}/${total}: ${name}`);
  }
});

console.log(results.hallucinations); // packages that don't exist
console.log(results.scanInfo);       // scan statistics
console.log(results.jsonReport);     // full JSON report

🧠 How It Works

The scanner uses regex patterns to detect:

  • ES6 imports: import X from 'package'
  • CommonJS: require('package')
  • Dynamic imports: import('package')

It automatically ignores:

  • Relative imports (./utils, ../lib)
  • Node.js built-ins (fs, path, crypto, etc.)
  • node_modules/, dist/, build/ directories
  • Minified and bundled files

Each unique package name is then checked against the npm registry API. Packages returning a 404 are flagged as hallucinations.

🗺️ Roadmap

This is part of a bigger vision. Coming soon:

  • code-decay — Freshness scores for your files
  • vibe-check — Get quizzed on your own code before deploying
  • karma — Your developer write/understand/test ratio
  • vibe-audit — The all-in-one suite

📄 License

MIT


Built for the vibe coding era. ✌️