{"record":{"id":"41b235b2bbdee93b","repo":"tauri-apps/tauri","slug":"failed-to-install-npm-dependencies-str","errorCode":null,"errorMessage":"Failed to install NPM {dependencies_str}","messagePattern":"Failed to install NPM (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-cli/src/helpers/npm.rs","lineNumber":162,"sourceCode":"\n    let mut command = self.cross_command();\n    command.arg(\"add\");\n\n    match self {\n      PackageManager::Deno => command.args(dependencies.iter().map(|d| format!(\"npm:{d}\"))),\n      _ => command.args(dependencies),\n    };\n\n    let status = command\n      .current_dir(frontend_dir)\n      .status()\n      .map_err(|error| Error::CommandFailed {\n        command: format!(\"failed to run {self}\"),\n        error,\n      })?;\n\n    if !status.success() {\n      crate::error::bail!(\"Failed to install NPM {dependencies_str}\");\n    }\n\n    Ok(())\n  }\n\n  pub fn remove<P: AsRef<Path>>(\n    &self,\n    dependencies: &[String],\n    frontend_dir: P,\n  ) -> crate::Result<()> {\n    let dependencies_str = if dependencies.len() > 1 {\n      \"dependencies\"\n    } else {\n      \"dependency\"\n    };\n    log::info!(\n      \"Removing NPM {dependencies_str} {}...\",\n      dependencies","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/tauri-apps/tauri/blob/52e4b6e71d8632a7e648f866c442e287ecddee34/crates/tauri-cli/src/helpers/npm.rs#L144-L180","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","solutions":["Read the package manager's error printed above this line — it is the actual cause (ERESOLVE, E404, ETARGET, etc.)","Run the install manually in the frontend dir, e.g. `npm install @tauri-apps/plugin-x`, and resolve what it reports","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`"],"exampleFix":"# before: npm install fails with ERESOLVE under npm 7+\n# after: align peer versions in package.json\n\"dependencies\": { \"@tauri-apps/api\": \"^2.0.0\", \"@tauri-apps/plugin-dialog\": \"^2.0.0\" }","handlingStrategy":"validation","validationCode":"# preflight: package.json present, deps installed, registry reachable\ncd frontend\n[ -f package.json ] || { echo 'no package.json in frontend dir'; exit 1; }\nnpm ping >/dev/null 2>&1 || { echo 'npm registry unreachable'; exit 1; }\ntauri add my-plugin","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep `@tauri-apps/*` package versions aligned to avoid peer-dep rejections","Commit lockfiles and run `npm ci` (or equivalent) before `tauri add` in CI","Verify the frontend directory resolves to the folder containing `package.json` before plugin installs"],"tags":["tauri-cli","npm","dependencies","package-manager","frontend"],"backgroundTag":"dependency-install-failed","analyzedSha":"52e4b6e71d8632a7e648f866c442e287ecddee34","analyzedAt":"2026-08-20T13:59:20.734Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}