Skip to content

About

A Bash script to automatically detect missing dependencies and devDependencies in your JavaScript/React project and install them.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Auto-Install Dependencies for React/JS Projects

A Bash script to automatically detect missing dependencies and devDependencies in your JavaScript/React project and install them.
It scans your source code and test/config files, compares imports with package.json, and installs any missing packages with proper separation for dev vs production.


Features

  • Scans your src/ folder for imports, require() calls, and dynamic import() calls.
  • Classifies each import based on which file it came from: imports found in .test., .spec., __tests__, .eslintrc, jest.config, webpack.config, or vite.config files → devDependencies; everything else → dependencies.
  • Handles scoped packages correctly (e.g., @mui/material/Button → @mui/material, not truncated to @mui) and strips subpaths on plain packages (e.g., react-dom/client → react-dom).
  • Skips Node.js built-in modules (fs, path, crypto, etc.) so it never tries to npm install something that's already part of Node itself.
  • Skips path aliases (@/components/..., ~/utils/..., #/lib/...) so common Vite/webpack/Next.js/tsconfig aliases aren't mistaken for npm packages.
  • Dry-run & confirmation prompt before installing anything.
  • Works with modern React projects and most JS/TS projects.

Usage

  1. Clone or copy the script to your project root:
curl -O https://raw.githubusercontent.com/Fcharki/auto-install-deps/main/auto-install.sh
  1. Make the script executable:
chmod +x auto-install.sh
  1. Run the script:
./auto-install.sh
  1. The script will show what packages are missing and ask for confirmation before installing them.

Requirements

  • Bash shell (Git Bash, WSL, or Linux/macOS terminal)
  • jq installed and available in your PATH (download jq)
  • Node.js and npm installed

Safety & Notes

  • The script prompts for confirmation before installing anything, so you stay in control.
  • Avoid running it on production-only servers, it's designed for local development.
  • devDependency detection is based on the file an import comes from (test/config files), not the import text itself — make sure your test files actually match one of the recognized patterns (.test., .spec., __tests__, etc.) or their imports will be classified as regular dependencies.
  • Run it with a clean git status first so you can review git diff package.json after installing, before committing.

Known Limitations

  • Path alias prefixes are limited to @/, ~/, and #/. If your project uses a different alias convention, you'll need to add it to the script's alias check.
  • TypeScript type-only imports (import type { Foo } from 'bar') are treated the same as regular imports — usually fine, since you'd want the package installed either way.

License

This project is licensed under the MIT License. See LICENSE file for details.

About

A Bash script to automatically detect missing dependencies and devDependencies in your JavaScript/React project and install them.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages