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 🙏

© 2024 – Pkg Stats / Ryan Hefner

npm-fill-gaps

v1.0.15

Published

Automatically scans your JavaScript or TypeScript files for external imports and installs missing packages from `npm`.

Downloads

14

Readme

npm-fill-gaps

Automatically scans your JavaScript or TypeScript files for external imports and installs missing packages from npm.

Features:

  • Scans your project's JS/TS files for import statements.
  • Checks for missing dependencies in your package.json.
  • Installs any missing dependencies via npm.
  • Ignores relative paths and specific path notations like @/.

Installation:

While you don't need to install npm-fill-gaps globally, if you wish to use it without npx, you can do:

npm install -g npm-fill-gaps

Usage:

Using npx (recommended):

npx npm-fill-gaps

How It Works:

  1. The script scans your JS/TS files for import statements.
  2. It compares the found imports against the dependencies in your package.json.
  3. Any missing dependencies are then installed using npm.

Exclusions:

The following import paths/patterns are excluded from the scan:

  • Relative imports starting with ./ or ../.
  • Imports starting with @/ (e.g., aliases in some configurations).

Ignoring Specific Patterns

The --ignore flag allows you to specify patterns that should be excluded when scanning for imports. This is particularly useful if there are certain libraries or internal modules that you don't want to be automatically installed or checked against.

Usage:

npx npm-fill-gaps --ignore pattern1 pattern2 pattern3

For example, to ignore anything related to react, any import starting with @/, and any imports that start with jotai/, you can run:

npx npm-fill-gaps --ignore react @/** jotai/*

Patterns support the * wildcard character, making it easy to specify broader matching criteria. Each pattern is separated by a space.

Passing npm Flags

The script allows for passing npm-related flags directly to the npm install command, providing flexibility in how the installation process is executed.

Usage:

npx npm-fill-gaps --ignore somePattern --force --dry-run

In the above example, --force and --dry-run are passed directly to the npm install command.

Supported npm Flags:

  • --force: Force npm to fetch remote resources even if a local copy exists on disk.
  • --legacy-peer-deps: Install the package even if it has peer dependencies that conflict with already installed versions.
  • --no-save: Prevents saving to dependencies.
  • --dry-run: Indicates that you don't want npm to make any changes and just report what it would do.

You can append any of these flags after your regular script arguments, and they will be considered during the installation process.

Note:

  • Ensure you run the script in a directory containing your package.json.
  • The script assumes a standard import format. Complex import patterns or dynamic imports might not be captured accurately.
  • Always review and ensure you trust packages before allowing them to be installed.

Contributing:

We welcome contributions! Please open an issue or submit a PR if you have improvements, bug fixes, or new features.

License:

MIT License