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

Wails dev执行报错:无法找到wails.json,请求协助排查

Wails + Svelte 嵌套组件开发报错解决

问题背景

基于Wails + Svelte的Hello World项目,在开始嵌套组件开发前,wails dev或wails build运行完全正常。但在App.svelte同目录(...\1-hello_world\frontend\src)创建Nested.svelte组件后,出现异常提示:

  • 在项目根目录...\1-hello_world执行wails dev,终端提示找不到根目录下的wails.json,但该文件实际存放在...\1-hello_world\frontend\wails.json
  • 在frontend子目录执行wails dev,终端提示no Go files in ...\1-hello_world\frontend

代码文件内容

App.svelte

<script lang="ts">
  import Nested from "./Nested.svelte";
  let src = "./src/assets/images/bobby.png";
  const title = "Mr.";
  const height = "small";
</script>

<h3>Title of App - Hello Again {title.toUpperCase()} World</h3>

<p>Paragraph styling is scoped.</p>

<Nested />

<style>
  p {
    color: goldenrod;
    font-family: "Comic Sans MS", cursive;
    font-size: 2em;
  }
</style>

Nested.svelte

<script lang="ts">
</script>

<p>This is the nested paragraph.</p>

解决步骤

  1. 迁移配置文件到项目根目录:Wails框架要求wails.json必须放在项目根目录(即...\1-hello_world),将frontend/wails.json剪切到根目录下。
  2. 修正配置文件路径指向:打开根目录的wails.json,确认frontend.dir字段正确指向前端子目录:
    "frontend": {
      "dir": "./frontend",
      "installCommand": "npm install",
      "buildCommand": "npm run build",
      "devServerCommand": "npm run dev"
    }
    
  3. 重新执行开发命令:回到项目根目录,运行wails dev,此时Wails会正确读取配置文件,调用前端开发服务,嵌套组件也能正常加载。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.13 18:15:09