Skip to content

[bug] [android] [windows] [cli] [build] Android Build Error: A problem occurred starting process 'command 'C:\nvm4w\nodejs\node.exe.cmd'' and Error: Cannot find module '...tauri' when using nvm4w #13892

@DomanskiFilip

Description

@DomanskiFilip

Describe the bug

Hi everyone. I am a student working on my year 3 project useing tauri and I encoutered this issue:

Every time I attempt to start a new Tauri project and run tauri android dev on Windows, I consistently encounter a build failure. The primary errors indicate an issue with finding and executing Node.js via C:\nvm4w\nodejs\node.exe.cmd, followed by a Cannot find module '...tauri' error, and ultimately a Gradle build failure on the rustBuildX86_64Debug task.

ERROR LOGS:

        Finished `dev` profile [unoptimized + debuginfo] target(s) in 10.34s
            Info symlinking lib "E:\\uni\\year 3\\year 3 project\\CalendarAssistantApp\\CATdesktop\\src-tauri\\target\\x86_64-linux-android\\debug\\libapp_lib.so" in jniLibs dir "E:\\uni\\year 3\\year 3 project\\CalendarAssistantApp\\CATdesktop\\src-tauri\\gen/android\\app/src/main/jniLibs/x86_64"
            Info "E:\\uni\\year 3\\year 3 project\\CalendarAssistantApp\\CATdesktop\\src-tauri\\target\\x86_64-linux-android\\debug\\libapp_lib.so" requires shared lib "libandroid.so"
            Info "E:\\uni\\year 3\\year 3 project\\CalendarAssistantApp\\CATdesktop\\src-tauri\\target\\x86_64-linux-android\\debug\\libapp_lib.so" requires shared lib "libdl.so"
            Info "E:\\uni\\year 3\\year 3 project\\CalendarAssistantApp\\CATdesktop\\src-tauri\\target\\x86_64-linux-android\\debug\\libapp_lib.so" requires shared lib "liblog.so"
            Info "E:\\uni\\year 3\\year 3 project\\CalendarAssistantApp\\CATdesktop\\src-tauri\\target\\x86_64-linux-android\\debug\\libapp_lib.so" requires shared lib "libm.so"
            Info "E:\\uni\\year 3\\year 3 project\\CalendarAssistantApp\\CATdesktop\\src-tauri\\target\\x86_64-linux-android\\debug\\libapp_lib.so" requires shared lib "libc.so"
            Info symlink at "E:\\uni\\year 3\\year 3 project\\CalendarAssistantApp\\CATdesktop\\src-tauri\\gen/android\\app/src/main/jniLibs/arm64-v8a\\libapp_lib.so" points to "E:\\uni\\year 3\\year 3 project\\CalendarAssistantApp\\CATdesktop\\src-tauri\\target\\aarch64-linux-android\\release\\libapp_lib.so"
            Info symlink at "E:\\uni\\year 3\\year 3 project\\CalendarAssistantApp\\CATdesktop\\src-tauri\\gen/android\\app/src/main/jniLibs/x86_64\\libapp_lib.so" points to "E:\\uni\\year 3\\year 3 project\\CalendarAssistantApp\\CATdesktop\\src-tauri\\target\\x86_64-linux-android\\debug\\libapp_lib.so"
    node:internal/modules/cjs/loader:1146
      throw err;
      ^
    
    Error: Cannot find module 'E:\uni\year 3\year 3 project\CalendarAssistantApp\CATdesktop\src-tauri\tauri'
        at Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)
        at Module._load (node:internal/modules/cjs/loader:984:27)
        at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
        at node:internal/main/run_main_module:28:49 {
      code: 'MODULE_NOT_FOUND',
      requireStack: []
    }
    
    Node.js v20.12.2
    
    FAILURE: Build failed with an exception.
    
    Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
    
    You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
    
    For more on this, please refer to https://docs.gradle.org/8.14.3/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
    
    BUILD FAILED in 2s
    Failed to assemble APK: command ["E:\\uni\\year 3\\year 3 project\\CalendarAssistantApp\\CATdesktop\\src-tauri\\gen/android\\gradlew.bat", "--project-dir", "E:\\uni\\year 3\\year 3 project\\CalendarAssistantApp\\CATdesktop\\src-tauri\\gen/android"] exited with code 1: command ["E:\\uni\\year 3\\year 3 project\\CalendarAssistantApp\\CATdesktop\\src-tauri\\gen/android\\gradlew.bat", "--project-dir", "E:\\uni\\year 3\\year 3 project\\CalendarAssistantApp\\CATdesktop\\src-tauri\\gen/android"] exited with code 1
           Error Failed to assemble APK: command ["E:\\uni\\year 3\\year 3 project\\CalendarAssistantApp\\CATdesktop\\src-tauri\\gen/android\\gradlew.bat", "--project-dir", "E:\\uni\\year 3\\year 3 project\\CalendarAssistantApp\\CATdesktop\\src-tauri\\gen/android"] exited with code 1: command ["E:\\uni\\year 3\\year 3 project\\CalendarAssistantApp\\CATdesktop\\src-tauri\\gen/android\\gradlew.bat", "--project-dir", "E:\\uni\\year 3\\year 3 project\\CalendarAssistantApp\\CATdesktop\\src-tauri\\gen/android"] exited with code 1

after some digging and debugging I found that this seems to be because in autogenerated Gradle BuildTask.kt it throws a specific error in windows specificaly this is the file:


import java.io.File
import org.apache.tools.ant.taskdefs.condition.Os
import org.gradle.api.DefaultTask
import org.gradle.api.GradleException
import org.gradle.api.logging.LogLevel
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskAction

open class BuildTask : DefaultTask() {
    @Input
    var rootDirRel: String? = null
    @Input
    var target: String? = null
    @Input
    var release: Boolean? = null

    @TaskAction
    fun assemble() {
        val executable = """C:\nvm4w\nodejs\node.exe"""; // Or similar path
        try {
            runTauriCli(executable)
        } catch (e: Exception) {
            if (Os.isFamily(Os.FAMILY_WINDOWS)) {
                runTauriCli("$executable.cmd") // This part failed as node.exe.cmd didn't exist
            } else {
                throw e;
            }
        }
    }

    fun runTauriCli(executable: String) {
        // ... (rest of the function)
        val args = listOf("tauri", "android", "android-studio-script"); // These args were passed to the Node.js executable
        // ... (rest of the function)
    }
}

my solution was to change the file to this:


import java.io.File
import org.apache.tools.ant.taskdefs.condition.Os
import org.gradle.api.DefaultTask
import org.gradle.api.GradleException
import org.gradle.api.logging.LogLevel
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskAction

open class BuildTask : DefaultTask() {
    @Input
    var rootDirRel: String? = null
    @Input
    var target: String? = null
    @Input
    var release: Boolean? = null

    @TaskAction
    fun assemble() {
        // The executable should be 'cargo'
        val cargoExecutable = if (Os.isFamily(Os.FAMILY_WINDOWS)) "cargo.exe" else "cargo" // Ensures 'cargo' is used
        runTauriCli(cargoExecutable)
    }

    fun runTauriCli(executable: String) {
        val rootDirRel = rootDirRel ?: throw GradleException("rootDirRel cannot be null")
        val target = target ?: throw GradleException("target cannot be null")
        val release = release ?: throw GradleException("release cannot be null")

        // Arguments for 'cargo tauri'
        val args = mutableListOf(
            "tauri",
            "android",
            "android-studio-script",
            "--target", target
        )

        if (release) {
            args.add("--release")
        }

        if (project.logger.isEnabled(LogLevel.DEBUG)) {
            args.add("-vv")
        } else if (project.logger.isEnabled(LogLevel.INFO)) {
            args.add("-v")
        }

        project.exec {
            workingDir(File(project.projectDir, rootDirRel))
            executable(executable) // This will now be "cargo"
            args(args)
        }.assertNormalExitValue()
    }
}

and this fixed the problem. As sstated I am a student and I dont know if this is a known issue or not but because it was showing every time I wanted to build an android app even clean tauri+vue apps I figured I share this to mybe help somebody

Expected behavior

The tauri android dev command should successfully compile and run the application on the detected Android device/emulator without manual intervention to the generated Gradle build files.

Actual Behavior
The build fails with errors indicating that Node.js cannot be found or invoked correctly by the Gradle BuildTask, specifically looking for node.exe.cmd and then misinterpreting the tauri command as a Node.js script.

Full tauri info output

> [email protected] tauri
> tauri info


[✔] Environment
    - OS: Windows 10.0.22631 x86_64 (X64)
    ✔ WebView2: 138.0.3351.95
    ✔ MSVC: Visual Studio Community 2022
    ✔ rustc: 1.87.0 (17067e9ac 2025-05-09)
    ✔ cargo: 1.87.0 (99624be96 2025-05-06)
    ✔ rustup: 1.28.2 (e4f3ad6f8 2025-04-28)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 20.12.2
    - npm: 10.5.0

[-] Packages
    - tauri 🦀: 2.7.0
    - tauri-build 🦀: 2.3.1
    - wry 🦀: 0.52.1
    - tao 🦀: 0.34.0
    - tauri-cli 🦀: 2.7.1
    - @tauri-apps/api : 2.7.0
    - @tauri-apps/cli : 2.7.1

[-] Plugins
    - tauri-plugin-log 🦀: 2.6.0
    - @tauri-apps/plugin-log : not installed!

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:5173/
    - framework: Vue.js
    - bundler: Vite

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions