tauri-apps/tauri · error · Error
Native binding package version mismatch, expected 2.11.4 but
Error message
Native binding package version mismatch, expected 2.11.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue. What it means
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.
Source
Thrown at packages/cli/index.js:85
function requireNative() {
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
try {
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
} catch (err) {
loadErrors.push(err)
}
} else if (process.platform === 'android') {
if (process.arch === 'arm64') {
try {
return require('./cli.android-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@tauri-apps/cli-android-arm64')
const bindingPackageVersion = require('@tauri-apps/cli-android-arm64/package.json').version
if (bindingPackageVersion !== '2.11.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 2.11.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm') {
try {
return require('./cli.android-arm-eabi.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@tauri-apps/cli-android-arm-eabi')
const bindingPackageVersion = require('@tauri-apps/cli-android-arm-eabi/package.json').version
if (bindingPackageVersion !== '2.11.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 2.11.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return bindingView on GitHub (pinned to 2f1cd75b0f)
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.
Example fix
// before: lockfile pins @tauri-apps/cli-android-arm64@2.7.1, @tauri-apps/cli is 2.11.4 NAPI_RS_ENFORCE_VERSION_CHECK=1 npx tauri dev // Error: Cannot find native binding ... cause: expected 2.11.4 but got 2.7.1 // after rm -rf node_modules package-lock.json && npm install npm ls @tauri-apps/cli-android-arm64 // -> 2.11.4 npx tauri dev
Defensive patterns
Strategy: try-catch
Validate before calling
const fs = require('node:fs')
// call before require('@tauri-apps/cli') on Android arm64
function isNativeBindingVersionOk() {
try {
const pkgPath = require.resolve('@tauri-apps/cli-android-arm64/package.json')
const version = JSON.parse(fs.readFileSync(pkgPath, 'utf8')).version
return version === '2.11.4'
} catch {
return false // package absent: loader reports its own error
}
} Try / catch
try {
const cli = require('@tauri-apps/cli')
} catch (err) {
let cause = err
let mismatch = false
while (cause) {
if (/Native binding package version mismatch/.test(String(cause.message))) mismatch = true
cause = cause.cause
}
if (mismatch) {
// fix: rm -rf node_modules package-lock.json && npm install, then retry once
} else {
throw err
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of tauri-apps/tauri@2f1cd75b0f (2026-08-16).
Data as JSON: /api/errors/8b678dcda4946ea7.
Report an issue: GitHub.