UNPKG

saksh-pc2

Version:

Check required packages in a JavaScript file

98 lines (63 loc) 2.09 kB
# 📦 saksh-pc2 - Node.js Package Checker `saksh-pc2` is a lightweight CLI tool that scans a JavaScript file to detect external dependencies (`require()` and `import` statements). It then suggests an `npm install` command to install missing packages. --- ## 🚀 Installation To install `saksh-pc2` globally, run: ```bash npm install -g saksh-pc2 ``` After installation, you can use the `saksh-pc2` command from anywhere in your terminal. --- ## 🛠️ Usage ### **1️⃣ Check External Dependencies** To check which external packages are used in a JavaScript file, run: ```bash saksh-pc2 app.js ``` ### **2️⃣ Example Output** If your file `app.js` contains: ```js const express = require("express"); const mongoose = require("mongoose"); console.log("Server running..."); ``` Running `saksh-pc2 app.js` will output: ``` 📦 Detected external packages: express mongoose 💡 To install them, run: npm install express mongoose ``` If no external packages are found: ``` No external packages detected. ``` --- ## ⚙️ Features **Scans JavaScript files for dependencies** **Supports both `require()` (CommonJS) and `import` (ES Modules)** **Generates an `npm install` command** **Fast and lightweight** **No dependencies on large libraries** --- ## 💡 Why Use `saksh-pc2`? - Quickly check for missing dependencies before running your script. - Prevent `Module Not Found` errors in production. - Ensure all required packages are installed before deployment. - Simple and fast, with minimal dependencies. --- ## 🔧 Advanced Usage If you want to **automatically install missing dependencies**, you can modify the command: ```bash saksh-pc2 app.js | xargs npm install ``` This will scan for missing packages and **install them automatically**. --- ## 🏗️ Contributing If you find a bug or have suggestions, feel free to open an issue or submit a pull request. --- ## 📜 License MIT License. --- Happy coding! 🚀