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: preserve lockfiles during managed installs

[._.]/ Adam Eivy1bda1d7db041
diff --git a/README.md b/README.md
index 11a8d3bb9d..278aff3b40 100644
--- a/README.md
+++ b/README.md
@@ -291,7 +291,7 @@ Track your biological self alongside your digital one.
### Requirements
- Node.js 22.12 or later (24 is what CI and `.nvmrc` use; Vite 8 requires ≥20.19). `npm run setup`, `npm start` and `npm run dev` check this first and stop immediately on an older Node — a bare `npm install` only warns, so use the commands below.
-- npm 12 or later (`npm install -g npm@latest`). Older npm installs fine, but its lockfile writer omits the `libc` fields npm 12 records, so every `npm install` rewrites `client/package-lock.json` and `server/package-lock.json` — and the next Dependabot PR puts those fields back. Every workspace declares `engines.npm`, so npm warns on any install path; `npm run setup`/`start`/`dev` also print what to do about it. These are warnings, never failures. No Node release bundles npm 12 yet (Node 24.10 ships 11.6.1), so this is a deliberate global upgrade — and worth checking `npm -v` matches, since an old global npm earlier on `PATH` shadows the one Node ships.
+- npm 12 or later (`npm install -g npm@latest`) for dependency authoring. Older npm installs dependencies correctly, but its lockfile writer omits the `libc` fields npm 12 records, so a direct `npm install` can rewrite `client/package-lock.json` and `server/package-lock.json` — and the next Dependabot PR puts those fields back. PortOS-managed setup, update, and dependency-repair installs preserve the committed lockfiles with `--no-save`; do not commit metadata-only churn from an older npm. Every workspace declares `engines.npm`, so npm warns on any install path; `npm run setup`/`start`/`dev` also print what to do about it. These are warnings, never failures. No Node release bundles npm 12 yet (Node 24.10 ships 11.6.1), so this is a deliberate global upgrade — and worth checking `npm -v` matches, since an old global npm earlier on `PATH` shadows the one Node ships.
- Git
- PostgreSQL, either installed locally or available through Docker. PortOS requires a healthy database; the setup command provisions the supported local or Docker-backed instance.
diff --git a/package.json b/package.json
index f676e69d6f..5e514749ae 100644
--- a/package.json
+++ b/package.json
@@ -27,7 +27,7 @@
"install:all": "npm run setup",
"doctor": "node scripts/doctor.js",
"migrations": "node scripts/run-migrations.js",
- "setup": "node scripts/checkNodeVersion.js && node scripts/checkNpmVersion.js && git submodule update --init --recursive && npm install && npm install --prefix client && npm install --prefix server && npm install --prefix autofixer && node scripts/trusted-rebuilds.js server && node scripts/setup-data.js && node scripts/setup-db.js && node scripts/setup-llm.js && node scripts/setup-browser.js",
+ "setup": "node scripts/checkNodeVersion.js && node scripts/checkNpmVersion.js && git submodule update --init --recursive && npm install --no-save && npm install --no-save --prefix client && npm install --no-save --prefix server && npm install --no-save --prefix autofixer && node scripts/trusted-rebuilds.js server && node scripts/setup-data.js && node scripts/setup-db.js && node scripts/setup-llm.js && node scripts/setup-browser.js",
"setup:data": "node scripts/setup-data.js",
"setup:db": "node scripts/setup-db.js",
"setup:db:test": "npm run setup:db:test --prefix server",
diff --git a/scripts/checkNpmVersion.js b/scripts/checkNpmVersion.js
index 4017f0b3d0..d3b4305aac 100644
--- a/scripts/checkNpmVersion.js
+++ b/scripts/checkNpmVersion.js
@@ -15,15 +15,17 @@
* npm versions disagree about the schema, so the file ping-pongs forever. The
* same skew drops `peer: true` markers that npm 12 records.
*
- * Why this warns instead of failing: no Node release bundles npm 12 yet (Node
- * 24.10 ships npm 11.6.1), so gating `npm start` on it would break working
- * installs over a file-formatting difference. An install on an older npm is
- * correct — it just churns the lockfile. `npm install -g npm@latest` ends it.
+ * PortOS-managed setup, update, and dependency-repair installs pass `--no-save`
+ * so they honor the committed lockfile without rewriting it. A direct
+ * dependency-authoring `npm install` on an older npm still churns the lockfile.
+ * No Node release bundles npm 12 yet (Node 24.10 ships npm 11.6.1), so gating
+ * installs on it would break working installs over a file-formatting difference.
+ * `npm install -g npm@latest` ends the mismatch for authoring workflows.
*
* This advisory is the explainer, not the whole floor. The four `engines.npm`
* fields are the declarative half, and they are what covers the install paths
- * this script never sees — `cd client && npm install`, `npm i <pkg>`, `npm ci`
- * — because npm checks them itself and prints EBADENGINE. `engine-strict` stays
+ * this script never sees — `cd client && npm install` and `npm i <pkg>` —
+ * because npm checks them itself and prints EBADENGINE. `engine-strict` stays
* off (see the .npmrc note: it would make one dependency's narrow range break
* every install), so those stay warnings too.
*
@@ -102,8 +104,8 @@ export function npmAdvisory({
if (compareVersions(npmVersion, MIN_NPM) >= 0) return [];
const lines = [
- `⚠️ npm ${npmVersion} is below ${MIN_NPM} — installs will rewrite package-lock.json`,
- 'ℹ️ Older npm drops the `libc` fields npm 12 records, so the lockfiles churn on every install and ping-pong with Dependabot'
+ `⚠️ npm ${npmVersion} is below ${MIN_NPM} — direct npm installs can rewrite package-lock.json`,
+ 'ℹ️ Older npm drops the `libc` fields npm 12 records, so direct installs churn the lockfiles and ping-pong with Dependabot'
];
// The confusing case: PATH is resolving an older global npm ahead of the one
diff --git a/scripts/checkNpmVersion.test.js b/scripts/checkNpmVersion.test.js
index 5be99cd096..1dad789a95 100644
--- a/scripts/checkNpmVersion.test.js
+++ b/scripts/checkNpmVersion.test.js
@@ -154,10 +154,32 @@ describe('the advisory is actually reachable', () => {
});
});
+describe('PortOS-managed installs preserve committed lockfiles', () => {
+ it('passes --no-save through every setup, update, and dependency-repair install', () => {
+ const managedEntrypoints = [
+ ['package.json', /npm install(?: --prefix \w+)?/g],
+ ['setup.ps1', /^npm install/gm],
+ ['update.ps1', /Invoke-Logged npm install/g],
+ ['update.sh', /run npm install/g],
+ ['scripts/ensure-deps.js', /npmSpawn\(\['install'/g],
+ ];
+
+ for (const [rel, installPattern] of managedEntrypoints) {
+ const body = readFileSync(join(REPO_ROOT, rel), 'utf8');
+ const installs = [...body.matchAll(installPattern)];
+ expect(installs.length, `${rel} has no managed npm installs to verify`).toBeGreaterThan(0);
+ for (const install of installs) {
+ const command = body.slice(install.index, install.index + 80);
+ expect(command, `${rel}: ${install[0]} must preserve package-lock.json`).toContain('--no-save');
+ }
+ }
+ });
+});
+
describe('the floor is declared where npm itself reads it', () => {
// The three scripts above cover `npm run setup|start|dev` and nothing else.
- // `cd client && npm install`, `npm i <pkg>` and `npm ci` are how the lockfile
- // churn actually gets introduced, and only `engines.npm` reaches those.
+ // Direct `cd client && npm install` and `npm i <pkg>` are how lockfile churn
+ // still gets introduced; only `engines.npm` reaches those authoring paths.
const MANIFESTS = ['package.json', 'client/package.json', 'server/package.json', 'autofixer/package.json'];
it.each(MANIFESTS)('%s declares engines.npm = the floor', (rel) => {
diff --git a/scripts/ensure-deps.js b/scripts/ensure-deps.js
index cdda3e453a..3bd5a5ac04 100644
--- a/scripts/ensure-deps.js
+++ b/scripts/ensure-deps.js
@@ -117,7 +117,9 @@ function cleanWorkspaceDeps(dir) {
function install(dir, label) {
try {
- npmSpawn(['install'], { cwd: dir, stdio: 'inherit', windowsHide: true });
+ // This repairs an installed tree; it never authors dependencies. Keep the
+ // committed lockfile byte-stable even when the local npm writer is older.
+ npmSpawn(['install', '--no-save'], { cwd: dir, stdio: 'inherit', windowsHide: true });
return rebuildTrusted(dir, label);
} catch (err) {
console.error(`⚠️ npm install failed for ${label}: ${err.message ?? err}`);
@@ -129,7 +131,7 @@ function install(dir, label) {
return false;
}
try {
- npmSpawn(['install'], { cwd: dir, stdio: 'inherit', windowsHide: true });
+ npmSpawn(['install', '--no-save'], { cwd: dir, stdio: 'inherit', windowsHide: true });
return rebuildTrusted(dir, label);
} catch (retryErr) {
console.error(`❌ npm install failed for ${label} after retry: ${retryErr.message ?? retryErr}`);
diff --git a/setup.ps1 b/setup.ps1
index 43c534e07b..3cbb04c122 100644
--- a/setup.ps1
+++ b/setup.ps1
@@ -38,30 +38,31 @@ git submodule update --init --recursive
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
Write-Host ""
-# Install dependencies — use Push-Location instead of --prefix so npm doesn't
-# create a directory symlink (root package into sub-package node_modules), which
-# requires Developer Mode or admin rights on Windows.
+# Install dependencies — --no-save honors each committed lockfile without
+# rewriting it through the local npm's lockfile schema. Use Push-Location instead
+# of --prefix so npm doesn't create a directory symlink (root package into
+# sub-package node_modules), which requires Developer Mode or admin rights on Windows.
Write-Host "Installing dependencies..." -ForegroundColor Yellow
Write-Host " Installing root dependencies..."
-npm install
+npm install --no-save
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
Write-Host " Installing client dependencies..."
Push-Location client
-npm install
+npm install --no-save
if ($LASTEXITCODE -ne 0) { Pop-Location; exit $LASTEXITCODE }
Pop-Location
Write-Host " Installing server dependencies..."
Push-Location server
-npm install
+npm install --no-save
if ($LASTEXITCODE -ne 0) { Pop-Location; exit $LASTEXITCODE }
Pop-Location
Write-Host " Installing autofixer dependencies..."
Push-Location autofixer
-npm install
+npm install --no-save
if ($LASTEXITCODE -ne 0) { Pop-Location; exit $LASTEXITCODE }
Pop-Location
diff --git a/update.ps1 b/update.ps1
index 861626a4fb..e7719b0453 100644
--- a/update.ps1
+++ b/update.ps1
@@ -134,14 +134,17 @@ function Safe-Install {
Write-SafeHost "📦 Installing deps ($Label)..." -ForegroundColor Yellow
Push-Location $Dir
- Invoke-Logged npm install
+ # This is an installation/reconciliation path, not dependency authoring.
+ # --no-save still honors package-lock.json but prevents older npm versions
+ # from rewriting newer lockfile metadata (for example `libc` fields).
+ Invoke-Logged npm install --no-save
if ($LASTEXITCODE -eq 0) { Pop-Location; return }
Write-SafeHost "⚠️ npm install failed for $Label — cleaning node_modules + package-lock.json and retrying..." -ForegroundColor Yellow
Pop-Location
Clear-WorkspaceDeps -Dir $Dir
Push-Location $Dir
- Invoke-Logged npm install
+ Invoke-Logged npm install --no-save
if ($LASTEXITCODE -eq 0) { Pop-Location; return }
Pop-Location
diff --git a/update.sh b/update.sh
index 575a0642d5..8a3e09492d 100755
--- a/update.sh
+++ b/update.sh
@@ -92,13 +92,16 @@ safe_install() {
fi
log "📦 Installing deps ($label)..."
- if (cd "$dir" && run npm install); then
+ # This is an installation/reconciliation path, not dependency authoring.
+ # --no-save still honors package-lock.json but prevents older npm versions
+ # from rewriting newer lockfile metadata (for example `libc` fields).
+ if (cd "$dir" && run npm install --no-save); then
return 0
fi
log "⚠️ npm install failed for $label — cleaning node_modules + package-lock.json and retrying..."
clean_workspace_deps "$dir"
- if (cd "$dir" && run npm install); then
+ if (cd "$dir" && run npm install --no-save); then
return 0
fi