mastra-ai/mastra · error
${err instanceof Error ? err.message : String(err)}\nYou can
Error message
${err instanceof Error ? err.message : String(err)}\nYou can retry manually: cd ${projectName} && ${packageManager} install What it means
The create() command in mastracode/mastra-factory/src/create.ts wraps the dependency-install step (a spawned package-manager process with throwOnError: true) in try/catch. When the install command exits non-zero, the spinner stops with 'Dependency install failed.' and the original error message is re-thrown with a manual-retry hint: cd into the generated project and run the chosen package manager's install yourself.
Source
Thrown at mastracode/mastra-factory/src/create.ts:131
}
spinner.stop('Template downloaded.');
} catch (err) {
spinner.stop('Template download failed.');
throw err;
}
// ── Install dependencies ─────────────────────────────────────────────────
const installSpinner = p.spinner();
installSpinner.start(`Installing dependencies...`);
try {
await x(packageManager, getInstallArgs(packageManager), {
throwOnError: true,
nodeOptions: { cwd: projectPath },
});
installSpinner.stop('Dependencies installed.');
} catch (err) {
installSpinner.stop('Dependency install failed.');
throw new Error(
`${err instanceof Error ? err.message : String(err)}\nYou can retry manually: cd ${projectName} && ${packageManager} install`,
);
}
// ── Platform provisioning ────────────────────────────────────────────────
let platformResult: PlatformProvisionResult | null = null;
let platformError: string | null = null;
let platformSkipped = false;
if (!args.noPlatform) {
try {
platformResult = await runPlatformProvisioning({
projectName,
projectPath,
region: requestedRegion,
org: args.org,
});
} catch (err) {
if (err instanceof LoginCancelledError) {View on GitHub (pinned to 75dd419e61)
Solutions
- Follow the hint: cd <projectName> && <packageManager> install — transient network failures often succeed on retry.
- Verify the package manager binary exists and is on PATH (e.g. `pnpm --version`); install it or pass a different packageManager choice.
- Check network/registry access and auth (NPM_TOKEN, .npmrc, proxy env vars).
- Confirm Node version satisfies the generated project's engines field and upgrade if needed.
- Clear the package manager cache if corruption is suspected, then rerun install manually.
Example fix
// before: generated project fails install due to missing pnpm $ mastra-factory create my-app --package-manager pnpm Error: spawn pnpm ENOENT\nYou can retry manually: cd my-app && pnpm install // after: ensure the manager exists first command -v pnpm >/dev/null || npm i -g pnpm $ mastra-factory create my-app --package-manager pnpm
Defensive patterns
Strategy: try-catch
Validate before calling
import { execSync } from 'node:child_process';
// pre-flight before invoking the generator
try { execSync(`${packageManager} --version`, { stdio: 'ignore' }); }
catch { throw new Error(`${packageManager} is not installed or not on PATH`); }
execSync('curl -sf https://registry.npmjs.org/-/ping', { stdio: 'ignore' }); // registry reachable Try / catch
try {
await create(args);
} catch (err) {
const msg = err instanceof Error ? err.message : String(err);
if (msg.includes('retry manually')) {
const [_, projectName, pm] = msg.match(/cd (\S+) && (\S+) install/) ?? [];
execSync(`cd ${projectName} && ${pm} install`, { stdio: 'inherit' }); // surface real install output
} else throw err;
} Prevention
- Pre-install the chosen package manager (pnpm/yarn/npm) and confirm it's on PATH before scaffolding.
- Ensure registry access: set NPM_TOKEN/.npmrc and proxy env vars in CI.
- Pin a Node version matching the generated project's engines field (use nvm/.nvmrc).
- On failure, run the suggested manual install — it shows the real npm/pnpm error the wrapper swallowed.
When it happens
Trigger: The spawned `${packageManager} install` in the freshly scaffolded projectPath exits non-zero: no network/registry unreachable, private registry auth missing (NPM_TOKEN), unsupported Node version for a dependency, package manager binary not installed (e.g. pnpm absent), lockfile/platform-specific optional deps failing, or disk/permission errors in the target directory.
Common situations: Corporate proxy or offline CI blocking registry.npmjs.org; running the generator in a container without pnpm/yarn installed while the scaffold defaults to it; Node engine mismatch (newer packages requiring Node 20+); postinstall scripts blocked by --ignore-scripts security policy; ratelimited or authenticated npm registry.
Related errors
- HTTP_ERROR
- REQUEST_TIMEOUT
- SERVER_UNREACHABLE
- Failed to fetch logs: ${error.detail}
- Failed to stream logs: ${resp.status} — ${text}
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/54998f3a22c8c6e9.
Report an issue: GitHub.