Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: add npm scripts for pm2 to avoid command not found after setup

Adam Eivy875a19c93a8f
diff --git a/.changelog/v0.10.x.md b/.changelog/v0.10.x.md
index ac97ef5521..07f33fb042 100644
--- a/.changelog/v0.10.x.md
+++ b/.changelog/v0.10.x.md
@@ -222,6 +222,11 @@ This release introduces a structured changelog documentation system for creating
### Brain Memory Delete Handler
- **Fixed Delete Success Detection**: The MemoryTab delete handler was checking `result !== null` to determine success, but successful API responses might not return a value. Changed to track failures explicitly with a boolean flag, fixing false-positive "Deleted" toasts when delete operations failed
+### Setup Script pm2 Command Not Found
+- **Fixed post-setup pm2 availability**: After running `./setup.sh`, users would get "zsh: command not found: pm2" because pm2 is installed locally in `server/node_modules`, not globally
+- **Added npm scripts**: New `npm run pm2:start`, `npm run pm2:stop`, and `npm run pm2:logs` scripts that use `npx` to run the local pm2
+- **Updated documentation**: Setup script output and CLAUDE.md now reference the npm scripts instead of direct pm2 commands
+
### Critical: Fixed "Unexpected end of JSON input" Errors
- **Safe JSON Parsing**: Added comprehensive JSON parsing utilities to `server/lib/fileUtils.js`:
- `isValidJSON(str)` - Pre-validates JSON structure before parsing (supports both objects and arrays)
@@ -242,7 +247,7 @@ This release introduces a structured changelog documentation system for creating
git clone https://github.com/atomantic/PortOS.git
cd PortOS
npm run install:all
-pm2 start ecosystem.config.cjs
+npm run pm2:start
```
## 🔗 Full Changelog
diff --git a/CLAUDE.md b/CLAUDE.md
index 791189001e..439cecaab2 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -16,8 +16,9 @@ cd server && npm test
cd server && npm run test:watch # Watch mode
# Production
-pm2 start ecosystem.config.cjs
-pm2 logs
+npm run pm2:start
+npm run pm2:stop
+npm run pm2:logs
```
## Architecture
diff --git a/package.json b/package.json
index 03966d4d44..1c33bd323c 100644
--- a/package.json
+++ b/package.json
@@ -17,6 +17,9 @@
"dev:client": "cd client && npm run dev",
"build": "cd client && npm run build",
"start": "cd server && npm start",
+ "pm2:start": "npx pm2 start ecosystem.config.cjs",
+ "pm2:stop": "npx pm2 stop ecosystem.config.cjs",
+ "pm2:logs": "npx pm2 logs",
"install:all": "npm install && cd client && npm install && cd ../server && npm install && cd .. && npm run setup",
"setup": "node scripts/setup-data.js && node scripts/setup-browser.js",
"setup:data": "node scripts/setup-data.js",
diff --git a/setup.sh b/setup.sh
index 38f2a98f8c..ccff0c1517 100755
--- a/setup.sh
+++ b/setup.sh
@@ -35,7 +35,9 @@ echo "==================================="
echo ""
echo "Start PortOS:"
echo " Development: npm run dev"
-echo " Production: pm2 start ecosystem.config.cjs"
+echo " Production: npm run pm2:start"
+echo " Stop: npm run pm2:stop"
+echo " Logs: npm run pm2:logs"
echo ""
echo "Access at: http://localhost:5555"
echo ""