fix: drop apt nodejs/npm, install Node 22 directly via n (#1746)

apt-get install nodejs npm pulls in hundreds of node-* packages
(libhwasan, node-jsonify, node-eslint-utils, etc.) adding 60-90s
to cloud-init. We immediately replace it with Node 22 via n anyway.

Fix: bootstrap n directly from curl and install Node 22 in one step.
No apt nodejs/npm needed.

Before: apt install nodejs npm → npm install -g n → n 22 (slow)
After:  curl n | bash -s install 22 (fast, no apt bloat)

Co-authored-by: Claude <claude@anthropic.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
A 2026-02-22 12:40:22 -08:00 committed by GitHub
parent 0a8e6a30ad
commit 57d4ee7eeb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 29 additions and 31 deletions

View file

@ -15,7 +15,7 @@ import {
toKebabCase,
} from "../shared/ui";
import type { CloudInitTier } from "../shared/agents";
import { getPackagesForTier, needsNodeUpgrade, needsBun } from "../shared/cloud-init";
import { getPackagesForTier, needsNode, needsBun, NODE_INSTALL_CMD } from "../shared/cloud-init";
const DASHBOARD_URL = "https://lightsail.aws.amazon.com/";
@ -461,10 +461,10 @@ function getCloudInitUserdata(tier: CloudInitTier = "full"): string {
"apt-get update -y",
`apt-get install -y --no-install-recommends ${packages.join(" ")}`,
];
if (needsNodeUpgrade(tier)) {
if (needsNode(tier)) {
lines.push(
"# Upgrade Node.js to v22 LTS",
"npm install -g n && n 22 && ln -sf /usr/local/bin/node /usr/bin/node && ln -sf /usr/local/bin/npm /usr/bin/npm && ln -sf /usr/local/bin/npx /usr/bin/npx",
"# Install Node.js 22 via n",
`su - ubuntu -c '${NODE_INSTALL_CMD}'`,
"# Install Claude Code",
"su - ubuntu -c 'curl -fsSL https://claude.ai/install.sh | bash'",
"# Configure npm global prefix",