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.
- Scans your
src/folder for imports,require()calls, and dynamicimport()calls. - Classifies each import based on which file it came from: imports found in
.test.,.spec.,__tests__,.eslintrc,jest.config,webpack.config, orvite.configfiles →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 tonpm installsomething 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.
- Clone or copy the script to your project root:
curl -O https://raw.githubusercontent.com/Fcharki/auto-install-deps/main/auto-install.sh- Make the script executable:
chmod +x auto-install.sh- Run the script:
./auto-install.sh- The script will show what packages are missing and ask for confirmation before installing them.
- Bash shell (Git Bash, WSL, or Linux/macOS terminal)
- jq installed and available in your PATH (download jq)
- Node.js and npm installed
- 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 statusfirst so you can reviewgit diff package.jsonafter installing, before committing.
- 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.
This project is licensed under the MIT License. See LICENSE file for details.