mastra-ai/mastra · error · MastraError
NODE_FAIL_INSTALL_SPECIFIED_VERSION
NODE_FAIL_INSTALL_SPECIFIED_VERSION
Error message
NODE_FAIL_INSTALL_SPECIFIED_VERSION
What it means
installNodeVersion in deployers/cloud runs `n auto` in the bundle directory to provision the matching Node version for cloud deployment. When that subprocess exits non-zero, a MastraError with id NODE_FAIL_INSTALL_SPECIFIED_VERSION (category USER, domain DEPLOYER) is thrown, wrapping the execa error.
Source
Thrown at deployers/cloud/src/utils/deps.ts:79
// File does not exist
}
try {
fs.accessSync(join(path, '.node-version'));
nodeVersionExists = true;
} catch {
// File does not exist
}
if (nvmrcExists || nodeVersionExists) {
logger.info('Node version file found, installing specified Node.js version...');
const { success, error } = await runWithExeca({
cmd: 'n',
args: ['auto'],
cwd: path,
});
if (!success) {
throw new MastraError(
{
id: 'NODE_FAIL_INSTALL_SPECIFIED_VERSION',
category: 'USER',
domain: 'DEPLOYER',
},
error,
);
}
}
}
export async function installDeps({ path, pm }: { path: string; pm?: string }) {
pm = pm ?? detectPm({ path });
logger.info('Installing dependencies', { pm, path });
// --force is needed to install peer deps for external packages in the mastra output directory
// --legacy-peer-deps=false is needed to override other overrides by the repo package manager such as pnpm. Pnpm would set it to true
const args = ['install', '--legacy-peer-deps=false', '--force'];
const { success, error } = await runWithExeca({ cmd: pm, args, cwd: path });View on GitHub (pinned to 75dd419e61)
Solutions
- Install the `n` version manager and ensure it is on PATH
- Run with permission to write n's prefix (e.g. N_PREFIX with chown, or sudo-cached install)
- Verify network access to nodejs.org from the deploy environment
- Pre-install the required Node version yourself and retry the deploy
Example fix
// before $ mastra deploy cloud # fails: n not found // after $ npm i -g n && sudo mkdir -p /usr/local/n && sudo chown -R $(whoami) /usr/local/n $ mastra deploy cloud
Defensive patterns
Strategy: try-catch
Validate before calling
which n || { echo 'n version manager missing'; exit 1; }
node -e "fs.accessSync(process.env.N_PREFIX || '/usr/local/n', fs.constants.W_OK)" || echo 'n prefix not writable' Try / catch
try {
await installNodeVersion({ path, version });
} catch (err) {
if (err instanceof MastraError && err.id === 'NODE_FAIL_INSTALL_SPECIFIED_VERSION') {
console.error('n failed:', err.cause); // check PATH, N_PREFIX perms, network
} else throw err;
} Prevention
- Pre-install `n` and set a writable N_PREFIX in deploy images
- Verify network egress to nodejs.org in CI/deploy environments
- Pre-provision the exact Node version to avoid `n auto` at deploy time
- Run deploys with a user that owns n's install prefix
When it happens
Trigger: Calling installNodeVersion during a cloud deploy when the `n` node version manager fails to resolve/install the target version.
Common situations: `n` not installed or not on PATH; no write permission to /usr/local (n's default prefix); restricted network blocking nodejs.org downloads; unsupported/typos Node version resolution with 'auto'.
Related errors
- FAIL_INSTALL_DEPS
- FAIL_CUSTOM_INSTALL_COMMAND
- FAIL_BUILD_SCRIPT
- FAIL_BUILD_COMMAND
- IsolatedVmCodeModeTransport requires the --no-node-snapshot
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/316b90e09d98230c.
Report an issue: GitHub.