tauri-apps/tauri · error

Failed to install NPM {dependencies_str}

Error message

Failed to install NPM {dependencies_str}

What it means

The package-manager helper (`npm`/`pnpm`/`yarn`/`bun` chosen by lockfile detection) runs `install add <deps...>` in the frontend dir. When the package manager exits non-zero — its own output is printed above — the CLI reports which dependency string ('dependency'/'dependencies') failed to install.

Source

Thrown at crates/tauri-cli/src/helpers/npm.rs:162

    let mut command = self.cross_command();
    command.arg("add");

    match self {
      PackageManager::Deno => command.args(dependencies.iter().map(|d| format!("npm:{d}"))),
      _ => command.args(dependencies),
    };

    let status = command
      .current_dir(frontend_dir)
      .status()
      .map_err(|error| Error::CommandFailed {
        command: format!("failed to run {self}"),
        error,
      })?;

    if !status.success() {
      crate::error::bail!("Failed to install NPM {dependencies_str}");
    }

    Ok(())
  }

  pub fn remove<P: AsRef<Path>>(
    &self,
    dependencies: &[String],
    frontend_dir: P,
  ) -> crate::Result<()> {
    let dependencies_str = if dependencies.len() > 1 {
      "dependencies"
    } else {
      "dependency"
    };
    log::info!(
      "Removing NPM {dependencies_str} {}...",
      dependencies

View on GitHub (pinned to 52e4b6e71d)

Solutions

  1. Read the package manager's error printed above this line — it is the actual cause (ERESOLVE, E404, ETARGET, etc.)
  2. Run the install manually in the frontend dir, e.g. `npm install @tauri-apps/plugin-x`, and resolve what it reports
  3. For peer conflicts, align versions of `@tauri-apps/api` and the plugin, or use `--legacy-peer-deps`/an overrides block; verify the frontend dir contains `package.json`

Example fix

# before: npm install fails with ERESOLVE under npm 7+
# after: align peer versions in package.json
"dependencies": { "@tauri-apps/api": "^2.0.0", "@tauri-apps/plugin-dialog": "^2.0.0" }
Defensive patterns

Strategy: validation

Validate before calling

# preflight: package.json present, deps installed, registry reachable
cd frontend
[ -f package.json ] || { echo 'no package.json in frontend dir'; exit 1; }
npm ping >/dev/null 2>&1 || { echo 'npm registry unreachable'; exit 1; }
tauri add my-plugin

Prevention

When it happens

Trigger: `tauri add <plugin>` when the npm-side install fails: registry/network errors, ERESOLVE peer-dependency conflicts, lockfile out of sync with `package.json`, or a missing/invalid `package.json` in the resolved frontend directory.

Common situations: Strict peer deps (npm 7+) rejecting the new plugin package; offline or proxied CI; frontend dir misdetected so the package manager runs where no `package.json` exists; private registry auth missing.

Related errors


AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20). Data as JSON: /api/errors/41b235b2bbdee93b. Report an issue: GitHub.