Skip to content

[bug] pnpm tauri dev --no-watch error when starting dev server: #14284

@1298345095

Description

@1298345095

Describe the bug

When running pnpm tauri dev, if the --no-watch parameter is added, an error occurs on the second execution:
"error when starting dev server: Error: Port 996 is already in use", and the node.exe process is not closed.

Maybe like this #12141

Reproduction

vite.config.ts

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

// @ts-expect-error process is a nodejs global
const host = process.env.TAURI_DEV_HOST;

// https://vitejs.dev/config/
export default defineConfig(async () => ({
  plugins: [vue()],

  // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
  //
  // 1. prevent vite from obscuring rust errors
  clearScreen: false,
  // 2. tauri expects a fixed port, fail if that port is not available
  server: {
    port: 996,
    strictPort: true,
    host: host || false,
    hmr: host
      ? {
          protocol: "ws",
          host,
          port: 1421,
        }
      : undefined,
    watch: {
      // 3. tell vite to ignore watching `src-tauri`
      ignored: ["**/src-tauri/**"],
    },
  },
}));

Expected behavior

No response

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.26200 x86_64 (X64)
    ✔ WebView2: 141.0.3537.71
    ✔ MSVC: Visual Studio Enterprise 2022
    ✔ rustc: 1.90.0 (1159e78c4 2025-09-14)
    ✔ cargo: 1.90.0 (840b83a10 2025-07-30)
    ✔ rustup: 1.28.2 (e4f3ad6f8 2025-04-28)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 22.19.0
    - pnpm: 10.18.2
    - yarn: 1.22.22
    - npm: 10.9.3

[-] Packages
    - tauri 🦀: 2.8.5
    - tauri-build 🦀: 2.4.1
    - wry 🦀: 0.53.4
    - tao 🦀: 0.34.3
    - @tauri-apps/api : 2.8.0
    - @tauri-apps/cli : 2.8.4

[-] Plugins
    - tauri-plugin-opener 🦀: 2.5.0
    - @tauri-apps/plugin-opener : 2.5.0

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

Stack trace


Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions