Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

feat: add uninstall and full-uninstall npm scripts for cleaner removals

diegosouzapw1f7281064934
diff --git a/package.json b/package.json
index 6e422dc408..f20c62e204 100644
--- a/package.json
+++ b/package.json
@@ -85,6 +85,8 @@
"check": "npm run lint && npm run test",
"prepublishOnly": "npm run build:cli",
"postinstall": "node scripts/postinstall.mjs",
+ "uninstall": "node scripts/uninstall.mjs",
+ "uninstall:full": "node scripts/uninstall.mjs --full",
"prepare": "husky",
"system-info": "node scripts/system-info.mjs"
},
diff --git a/scripts/uninstall.mjs b/scripts/uninstall.mjs
new file mode 100644
index 0000000000..62ebe633bc
--- /dev/null
+++ b/scripts/uninstall.mjs
@@ -0,0 +1,49 @@
+import fs from "fs";
+import os from "os";
+import path from "path";
+import { execSync } from "child_process";
+
+const args = process.argv.slice(2);
+const fullUninstall = args.includes("--full");
+
+console.log("🛑 OmniRoute Uninstaller");
+console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
+
+// 1. Stop PM2 process if it exists
+try {
+ console.log("Stopping and removing background PM2 processes...");
+ execSync("pm2 delete omniroute 2>/dev/null", { stdio: "ignore" });
+} catch {
+ // It's perfectly fine if pm2 is not installed or the process doesn't exist.
+}
+
+// 2. Local AppData / Config Folder cleanup (Only on Full Uninstall)
+const dataDir = process.env.DATA_DIR || path.join(os.homedir(), ".omniroute");
+
+if (fullUninstall) {
+ console.log(`🧹 Full Uninstall selected. Erasing database and files at: ${dataDir}`);
+ try {
+ if (fs.existsSync(dataDir)) {
+ fs.rmSync(dataDir, { recursive: true, force: true });
+ console.log("✅ Data directory removed.");
+ } else {
+ console.log("ℹ️ Data directory did not exist. Skipping.");
+ }
+ } catch (error) {
+ console.warn("⚠️ Failed to remove data directory:", error.message);
+ }
+} else {
+ console.log(`💾 Keeping data files at: ${dataDir} intact.`);
+}
+
+// 3. NPM uninstall
+console.log("🗑️ Removing npm package...");
+try {
+ execSync("npm uninstall -g omniroute", { stdio: "inherit" });
+ console.log("\n✅ OmniRoute has been successfully uninstalled from your system.");
+ if (!fullUninstall) {
+ console.log(`ℹ️ Your configurations and databases were preserved in ${dataDir}.`);
+ }
+} catch (error) {
+ console.warn("⚠️ Failed to remove npm package. You might need to run this command with 'sudo'.");
+}