You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

修改Tauri图标、项目名称后启动报错,恢复默认仍异常求助

问题排查与解决

核心问题分析

你标注的Tauri版本10.8.1应为笔误(Tauri无此版本线),结合报错信息和配置格式,大概率是使用Tauri 1.x版本但配置混用了Tauri 2.x格式,同时存在字段格式错误,导致配置校验失败。

对应报错的具体原因

  • unknown property package:Tauri 1.x的根配置不存在package字段,产品名称和版本需放在tauri.bundle节点下
  • tauri has unknown property allowlist:若你使用的是Tauri 1.x早期版本,部分版本要求allowlist嵌套在tauri.security下(不过多数1.x版本支持直接放在tauri节点)
  • csp should be string:Tauri 1.x强制要求security.csp为字符串类型,不能设置为null
  • window has unknown property 0 + window should have required property 'title':实际读取的配置中可能误写为单数window(而非复数windows),把数组配置放到了单数字段下,导致解析异常

修复步骤

1. 修正tauri.conf.json配置(适配Tauri 1.x)

替换为符合1.x规范的配置,保留你的自定义项:

{
  "build": {
    "beforeDevCommand": "npm run dev",
    "beforeBuildCommand": "npm run build",
    "devPath": "http://localhost:1420",
    "distDir": "../dist"
  },
  "tauri": {
    "allowlist": {
      "all": false,
      "dialog": {
        "open": true,
        "message": true
      },
      "path": {
        "all": true
      },
      "shell": {
        "all": true,
        "execute": true,
        "sidecar": true,
        "open": true
      },
      "fs": {
        "all": true,
        "readFile": true,
        "writeFile": true,
        "readDir": true,
        "copyFile": true,
        "createDir": true,
        "removeDir": true,
        "removeFile": true,
        "renameFile": true,
        "exists": true,
        "scope": ["$APPDATA/**", "*/**"]
      }
    },
    "windows": [
      {
        "title": "converter-app",
        "width": 1000,
        "height": 600
      }
    ],
    "security": {
      "csp": "default-src 'self'; script-src 'self' 'unsafe-eval'"
    },
    "bundle": {
      "active": true,
      "targets": "all",
      "identifier": "com.tauri.dev",
      "productName": "converter-app",
      "version": "0.0.0",
      "icon": [
        "icons/32x32.png",
        "icons/128x128.png",
        "icons/128x128@2x.png",
        "icons/icon.icns",
        "icons/icon.ico"
      ]
    }
  }
}
  • 移除根节点的package字段,将productName和version移至tauri.bundle下
  • 将security.csp设置为符合要求的字符串(开发环境添加unsafe-eval避免热更新报错)
  • 确保窗口配置为复数windows数组

2. 清除缓存并重启服务

  • 删除项目根目录下的.tauri文件夹
  • 终止当前开发服务,重新执行npm run tauri dev

3. 确认Tauri版本

执行以下命令确认实际安装的版本,避免版本不匹配:

npm list @tauri-apps/cli

若版本为2.x,则需调整为Tauri 2.x的配置规范,但你的报错逻辑更适配1.x版本。

内容的提问来源于stack exchange,提问作者Migru

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 06:32:07