{"record":{"id":"8b678dcda4946ea7","repo":"tauri-apps/tauri","slug":"native-binding-package-version-mismatch-expected","errorCode":null,"errorMessage":"Native binding package version mismatch, expected 2.11.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.","messagePattern":"Native binding package version mismatch, expected 2\\.11\\.4 but got (.+?)\\. You can reinstall dependencies to fix this issue\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/index.js","lineNumber":85,"sourceCode":"function requireNative() {\n  if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {\n    try {\n      return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);\n    } catch (err) {\n      loadErrors.push(err)\n    }\n  } else if (process.platform === 'android') {\n    if (process.arch === 'arm64') {\n      try {\n        return require('./cli.android-arm64.node')\n      } catch (e) {\n        loadErrors.push(e)\n      }\n      try {\n        const binding = require('@tauri-apps/cli-android-arm64')\n        const bindingPackageVersion = require('@tauri-apps/cli-android-arm64/package.json').version\n        if (bindingPackageVersion !== '2.11.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {\n          throw new Error(`Native binding package version mismatch, expected 2.11.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)\n        }\n        return binding\n      } catch (e) {\n        loadErrors.push(e)\n      }\n    } else if (process.arch === 'arm') {\n      try {\n        return require('./cli.android-arm-eabi.node')\n      } catch (e) {\n        loadErrors.push(e)\n      }\n      try {\n        const binding = require('@tauri-apps/cli-android-arm-eabi')\n        const bindingPackageVersion = require('@tauri-apps/cli-android-arm-eabi/package.json').version\n        if (bindingPackageVersion !== '2.11.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {\n          throw new Error(`Native binding package version mismatch, expected 2.11.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)\n        }\n        return binding","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/tauri-apps/tauri/blob/2f1cd75b0f3fb72e6870d719bbfeadedcf8ca884/packages/cli/index.js#L67-L103","documentation":"The npm package @tauri-apps/cli is a napi-rs generated JS loader plus platform-specific native addons. On Android/arm64 it first requires the bundled ./cli.android-arm64.node, then falls back to the optional dependency @tauri-apps/cli-android-arm64. This error is thrown when that package resolves but its package.json version differs from the loader's version (2.11.4) and NAPI_RS_ENFORCE_VERSION_CHECK is set to a value other than '0'. The loader catches the throw, records it in loadErrors, and finally fails with 'Cannot find native binding' with this message in the cause chain. Without the env var set, a version mismatch is tolerated and the binding is returned.","triggerScenarios":"require('@tauri-apps/cli') (or npx tauri / tauri dev / tauri build) on Android arm64, when ./cli.android-arm64.node fails to load, @tauri-apps/cli-android-arm64 is installed at a version other than 2.11.4, and NAPI_RS_ENFORCE_VERSION_CHECK is truthy.","commonSituations":"npm optional-dependency bug (npm/cli#4828) left a stale @tauri-apps/cli-android-arm64 in node_modules. package-lock.json kept the old native package after @tauri-apps/cli was upgraded. CI reused a cached node_modules across a version bump. Someone enabled NAPI_RS_ENFORCE_VERSION_CHECK while the lockfile still pinned an older native package.","solutions":["Refresh dependencies: rm -rf node_modules package-lock.json && npm install. This clears stale optional dependencies.","Align versions: run npm ls @tauri-apps/cli-android-arm64 and upgrade with npm install -D @tauri-apps/cli@2.11.4 (or @latest) so every optional native dependency matches.","If the mismatch is intentional, disable the check: unset NAPI_RS_ENFORCE_VERSION_CHECK or set it to 0.","For CI, clear the node_modules cache layer and regenerate the lockfile after each @tauri-apps/cli upgrade."],"exampleFix":"// before: lockfile pins @tauri-apps/cli-android-arm64@2.7.1, @tauri-apps/cli is 2.11.4\nNAPI_RS_ENFORCE_VERSION_CHECK=1 npx tauri dev\n// Error: Cannot find native binding ... cause: expected 2.11.4 but got 2.7.1\n\n// after\nrm -rf node_modules package-lock.json && npm install\nnpm ls @tauri-apps/cli-android-arm64   // -> 2.11.4\nnpx tauri dev","handlingStrategy":"try-catch","validationCode":"const fs = require('node:fs')\n// call before require('@tauri-apps/cli') on Android arm64\nfunction isNativeBindingVersionOk() {\n  try {\n    const pkgPath = require.resolve('@tauri-apps/cli-android-arm64/package.json')\n    const version = JSON.parse(fs.readFileSync(pkgPath, 'utf8')).version\n    return version === '2.11.4'\n  } catch {\n    return false // package absent: loader reports its own error\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const cli = require('@tauri-apps/cli')\n} catch (err) {\n  let cause = err\n  let mismatch = false\n  while (cause) {\n    if (/Native binding package version mismatch/.test(String(cause.message))) mismatch = true\n    cause = cause.cause\n  }\n  if (mismatch) {\n    // fix: rm -rf node_modules package-lock.json && npm install, then retry once\n  } else {\n    throw err\n  }\n}","preventionTips":["Upgrade the Tauri CLI as one unit: npm install -D @tauri-apps/cli@latest; never pin @tauri-apps/cli-android-arm64 separately.","Regenerate the lockfile after each upgrade; do not reuse CI-cached node_modules across versions.","Assert in CI: npm ls @tauri-apps/cli-android-arm64 exits with the same version as @tauri-apps/cli.","Set NAPI_RS_ENFORCE_VERSION_CHECK only when every @tauri-apps/cli-* optional dependency is pinned at one version."],"tags":["napi-rs","native-binding","version-mismatch","tauri-cli","android","arm64"],"backgroundTag":null,"analyzedSha":"2f1cd75b0f3fb72e6870d719bbfeadedcf8ca884","analyzedAt":"2026-08-16T04:18:42.486Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}