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: Windows spawn ENOENT for pm2/npm commands

[._.]/ Adam Eivy8f7336f68ac8
diff --git a/.changelog/v1.4.x.md b/.changelog/v1.4.x.md
new file mode 100644
index 0000000000..80b93b9ad0
--- /dev/null
+++ b/.changelog/v1.4.x.md
@@ -0,0 +1,21 @@
+# Release v1.4.x - Changelog
+
+Released: Unreleased
+
+## Overview
+
+Cross-platform compatibility improvements for Windows and exFAT filesystems.
+
+## Fixes
+
+### Windows: spawn ENOENT for pm2 and npm commands
+- All `spawn('pm2', ...)` and `execFile('pm2', ...)` calls now use `shell: true` on Windows (`process.platform === 'win32'`), where pm2 is a `.cmd` wrapper that `spawn` can't find without shell
+- Affects: autofixer, browser service, CoS, log streaming, pm2 service, scaffold, socket service
+- Also fixes `spawn('npm', ...)` in scaffold route (same `.cmd` issue)
+
+### Windows/exFAT: npm install symlink failure
+- Removed npm `workspaces` config from root `package.json` — workspaces always create symlinks which fail on exFAT (no symlink support)
+- The `install:all` script and setup scripts already handle per-directory installs independently, so workspaces were unnecessary
+
+### Cross-platform path separators in PM2 config
+- `ecosystem.config.cjs` now uses `path.join()` instead of string concatenation for the Vite script and client cwd paths, avoiding mixed separators on Windows
diff --git a/autofixer/server.js b/autofixer/server.js
index 2d72c8e527..354e64e271 100644
--- a/autofixer/server.js
+++ b/autofixer/server.js
@@ -5,7 +5,8 @@ import { fileURLToPath } from 'url';
import { promisify } from 'util';
import { execFile as execFileCb } from 'child_process';
-const execFileAsync = promisify(execFileCb);
+const IS_WIN = process.platform === 'win32';
+const execFileAsync = (cmd, args, opts = {}) => promisify(execFileCb)(cmd, args, { shell: IS_WIN, ...opts });
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
diff --git a/autofixer/ui.js b/autofixer/ui.js
index 147515b222..a8c8780fba 100644
--- a/autofixer/ui.js
+++ b/autofixer/ui.js
@@ -885,7 +885,7 @@ app.get('/logs', async (req, res) => {
}
// Stream new logs
- pm2Process = spawn('pm2', ['logs', processName, '--lines', '0', '--raw']);
+ pm2Process = spawn('pm2', ['logs', processName, '--lines', '0', '--raw'], { shell: process.platform === 'win32' });
pm2Process.stdout.on('data', (data) => {
if (res.writableEnded) {
diff --git a/package-lock.json b/package-lock.json
index 07a1b1aa3b..62e27ba61b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "portos",
- "version": "1.4.0",
+ "version": "1.4.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "portos",
- "version": "1.4.0",
+ "version": "1.4.1",
"license": "MIT",
"dependencies": {
"express": "^4.21.2",
diff --git a/package.json b/package.json
index 52f6afc57e..446957bae8 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "portos",
- "version": "1.4.0",
+ "version": "1.4.1",
"private": true,
"description": "Local dev machine App OS portal",
"author": "Adam Eivy (@antic|@atomantic)",
diff --git a/server/routes/logs.js b/server/routes/logs.js
index 128b2ba4d7..0ca7976059 100644
--- a/server/routes/logs.js
+++ b/server/routes/logs.js
@@ -59,7 +59,7 @@ router.get('/:processName', asyncHandler(async (req, res) => {
// Spawn pm2 logs with --raw flag for clean output
// Security: safeProcessName is validated above to only contain safe characters
const logProcess = spawn('pm2', ['logs', safeProcessName, '--raw', '--lines', String(lines)], {
- shell: false
+ shell: process.platform === 'win32'
});
let buffer = '';
diff --git a/server/routes/scaffold.js b/server/routes/scaffold.js
index ff2a05ebf1..afa494418f 100644
--- a/server/routes/scaffold.js
+++ b/server/routes/scaffold.js
@@ -238,7 +238,7 @@ async function scaffoldApp(req, res) {
const { stderr } = await new Promise((resolve) => {
const child = spawn('npm', ['create', 'vite@latest', dirName, '--', '--template', 'react'], {
cwd: parentDir,
- shell: false
+ shell: process.platform === 'win32'
});
let stderr = '';
child.stderr.on('data', (data) => { stderr += data.toString(); });
diff --git a/server/services/browserService.js b/server/services/browserService.js
index 267994f9a4..9aa871ec1a 100644
--- a/server/services/browserService.js
+++ b/server/services/browserService.js
@@ -104,7 +104,7 @@ async function pm2Action(action, args) {
const execFileAsync = promisify(execFile);
console.log(`🌐 Browser PM2 ${action}: portos-browser`);
- await execFileAsync('pm2', [action, ...args]);
+ await execFileAsync('pm2', [action, ...args], { shell: process.platform === 'win32' });
console.log(`✅ Browser PM2 ${action} complete`);
// Give PM2 a moment to settle
@@ -135,7 +135,7 @@ export async function getProcessStatus() {
const { promisify } = await import('util');
const execFileAsync = promisify(execFile);
- const { stdout } = await execFileAsync('pm2', ['jlist']);
+ const { stdout } = await execFileAsync('pm2', ['jlist'], { shell: process.platform === 'win32' });
const processes = safeJSONParse(stdout, [], { allowArray: true });
const browserProc = processes.find(p => p.name === 'portos-browser');
@@ -164,7 +164,8 @@ export async function getRecentLogs(lines = 50) {
const execFileAsync = promisify(execFile);
const { stdout, stderr } = await execFileAsync('pm2', ['logs', 'portos-browser', '--nostream', '--lines', String(lines)], {
- timeout: 5000
+ timeout: 5000,
+ shell: process.platform === 'win32'
}).catch(() => ({ stdout: '', stderr: '' }));
return { stdout: stdout || '', stderr: stderr || '' };
diff --git a/server/services/cos.js b/server/services/cos.js
index fc06e78e77..95eeea3d32 100644
--- a/server/services/cos.js
+++ b/server/services/cos.js
@@ -2009,7 +2009,7 @@ export async function runHealthCheck() {
emitLog('warn', `🔄 ${names.length} errored PM2 process(es) detected: ${names.join(', ')} — attempting restart`);
const restartResults = await Promise.all(names.map(async (name) => {
- const result = await execFileAsync('pm2', ['restart', name]).catch(e => ({ stdout: '', stderr: e.message }));
+ const result = await execFileAsync('pm2', ['restart', name], { shell: process.platform === 'win32' }).catch(e => ({ stdout: '', stderr: e.message }));
const failed = result.stderr && !result.stdout;
if (failed) {
emitLog('error', `❌ Failed to restart ${name}: ${result.stderr}`);
diff --git a/server/services/pm2.js b/server/services/pm2.js
index 091cfc047b..6b1fe1adeb 100644
--- a/server/services/pm2.js
+++ b/server/services/pm2.js
@@ -3,6 +3,8 @@ import { spawn } from 'child_process';
import { existsSync } from 'fs';
import { extractJSONArray, safeJSONParse } from '../lib/fileUtils.js';
+const IS_WIN = process.platform === 'win32';
+
/**
* Build environment object with optional custom PM2_HOME
* @param {string} pm2Home Optional custom PM2_HOME path
@@ -29,7 +31,7 @@ function buildEnv(pm2Home) {
function spawnPm2Cli(action, name, pm2Home) {
return new Promise((resolve, reject) => {
const child = spawn('pm2', [action, name], {
- shell: false,
+ shell: IS_WIN,
env: buildEnv(pm2Home)
});
let stderr = '';
@@ -162,7 +164,7 @@ export async function deleteApp(name, pm2Home = null) {
export async function getAppStatus(name, pm2Home = null) {
return new Promise((resolve) => {
const child = spawn('pm2', ['jlist'], {
- shell: false,
+ shell: IS_WIN,
env: buildEnv(pm2Home)
});
let stdout = '';
@@ -209,7 +211,7 @@ export async function getAppStatus(name, pm2Home = null) {
export async function listProcesses(pm2Home = null) {
return new Promise((resolve) => {
const child = spawn('pm2', ['jlist'], {
- shell: false,
+ shell: IS_WIN,
env: buildEnv(pm2Home)
});
let stdout = '';
@@ -249,7 +251,7 @@ export async function getLogs(name, lines = 100, pm2Home = null) {
return new Promise((resolve, reject) => {
const args = ['logs', name, '--lines', String(lines), '--nostream', '--raw'];
const child = spawn('pm2', args, {
- shell: false,
+ shell: IS_WIN,
env: buildEnv(pm2Home)
});
@@ -325,7 +327,7 @@ export async function startFromEcosystem(cwd, processNames = [], pm2Home = null)
const child = spawn('pm2', args, {
cwd,
- shell: false,
+ shell: IS_WIN,
env: buildEnv(pm2Home)
});
let stdout = '';
diff --git a/server/services/socket.js b/server/services/socket.js
index 93105c1805..4419c213ad 100644
--- a/server/services/socket.js
+++ b/server/services/socket.js
@@ -140,7 +140,7 @@ export function initSocket(io) {
// Spawn pm2 logs with --raw flag
const logProcess = spawn('pm2', ['logs', processName, '--raw', '--lines', String(lines)], {
- shell: false
+ shell: process.platform === 'win32'
});
activeStreams.set(socket.id, { process: logProcess, processName });