vercel/next.js · error

Failed to parse Node.js version: '{}'

Error message

Failed to parse Node.js version: '{}'

What it means

Thrown by NodeJsEnvironment.runtime_versions() when Version::from_str fails to parse the Node.js version string. The version string comes either from `node --version` (via the process env / Current variant) or a Static configured version, and must parse into a semver Version; garbage input fails parsing.

Source

Thrown at turbopack/crates/turbopack-core/src/environment.rs:296

            cwd: ResolvedVc::cell(None),
        }
    }
}

#[turbo_tasks::value_impl]
impl NodeJsEnvironment {
    #[turbo_tasks::function]
    pub async fn runtime_versions(&self) -> Result<Vc<RuntimeVersions>> {
        let str = match *self.node_version.await? {
            NodeJsVersion::Current(process_env) => get_current_nodejs_version(*process_env),
            NodeJsVersion::Static(version) => *version,
        }
        .await?;

        Ok(Vc::cell(Versions {
            node: Some(
                Version::from_str(&str)
                    .map_err(|_| anyhow!("Failed to parse Node.js version: '{}'", str))?,
            ),
            ..Default::default()
        }))
    }

    #[turbo_tasks::function]
    pub async fn current(process_env: ResolvedVc<Box<dyn ProcessEnv>>) -> Result<Vc<Self>> {
        Ok(Self::cell(NodeJsEnvironment {
            compile_target: CompileTarget::current().to_resolved().await?,
            node_version: NodeJsVersion::cell(NodeJsVersion::Current(process_env))
                .to_resolved()
                .await?,
            cwd: ResolvedVc::cell(None),
        }))
    }
}

#[turbo_tasks::value(shared)]

View on GitHub (pinned to 0ae8c72462)

Solutions

  1. Run `node --version` and confirm it outputs a normal semver string like 'v20.11.0'; if not, switch to a standard Node.js build.
  2. If a static NodeJsVersion is configured, ensure it is valid semver (e.g. '20.11.0').
  3. Remove any env overrides that tamper with the detected Node version and rebuild.
Defensive patterns

Strategy: validation

Validate before calling

// Confirm a parseable Node version before building.
const { execSync } = require('child_process')
const v = execSync('node --version').toString().trim() // e.g. v20.11.0
if (!/^v?\d+\.\d+\.\d+/.test(v)) {
  throw new Error(`Unparseable Node.js version: '${v}'`)
}

Prevention

When it happens

Trigger: The detected Node.js version string (from get_current_nodejs_version or a static NodeJsVersion) is not valid semver — e.g. 'v', an empty string, a non-numeric tag, or a malformed custom version. Version::from_str rejects it and the error reports the offending string.

Common situations: A custom/packaged Node build reporting an unusual `node --version` output; NODEJS_VERSION-like env override set to a non-semver value; a forked Node runtime; corrupted version detection.

Understand the failure class

Related errors


AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06). Data as JSON: /api/errors/8dfc9703ea17575d. Report an issue: GitHub.