babalae/better-genshin-impact · error · FileNotFoundException

manifest.json文件不存在,请确认此脚本是JS脚本类型。{ManifestFile}

Error message

manifest.json文件不存在,请确认此脚本是JS脚本类型。{ManifestFile}

What it means

Thrown by the ScriptProject constructor when the project directory exists but manifest.json is missing from it. This is a FileNotFoundException indicating the folder is not a valid JS script project. The message suggests verifying the script type, since non-JS folders (like KeyMouse or Pathing) don't have manifest.json.

Source

Thrown at BetterGenshinImpact/Core/Script/Project/ScriptProject.cs:41

    public string ManifestFile { get; set; }

    public Manifest Manifest { get; set; }

    public string FolderName { get; set; }

    public ScriptProject(string folderName)
    {
        FolderName = folderName;
        ProjectPath = Path.Combine(Global.ScriptPath(), folderName);
        if (!Directory.Exists(ProjectPath))
        {
            throw new DirectoryNotFoundException("脚本文件夹不存在:" + ProjectPath);
        }

        ManifestFile = Path.GetFullPath(Path.Combine(ProjectPath, "manifest.json"));
        if (!File.Exists(ManifestFile))
        {
            throw new FileNotFoundException("manifest.json文件不存在,请确认此脚本是JS脚本类型。" + ManifestFile);
        }

        Manifest = Manifest.FromJson(File.ReadAllText(ManifestFile));
        Manifest.Validate(ProjectPath);
    }

    public ScrollViewer? LoadSettingUi(dynamic context)
    {
        var settingItems = Manifest.LoadSettingItems(ProjectPath);
        if (settingItems.Count == 0)
        {
            return null;
        }

        var stackPanel = new StackPanel
        {
            Margin = new Thickness(0, 0, 20, 0) // 给右侧滚动条留出位置
        };

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Verify the folder is actually a JS script project (should contain manifest.json and a main JS file).
  2. If the folder is a different type, fix the ScriptGroupProject.Type accordingly.
  3. Create or restore the manifest.json file in the project folder.
  4. Remove the invalid project entry from the script group configuration.
Defensive patterns

Strategy: validation

Validate before calling

string manifestFile = Path.Combine(projectPath, "manifest.json");
if (!File.Exists(manifestFile))
    throw new FileNotFoundException($"manifest.json not found at: {manifestFile}");

Type guard

static bool IsJavascriptProject(string folderName)
{
    var path = Path.Combine(Global.ScriptPath(), folderName, "manifest.json");
    return File.Exists(path);
}

Try / catch

try
{
    var project = new ScriptProject(folderName);
}
catch (FileNotFoundException ex) when (ex.Message.Contains("manifest.json文件不存在"))
{
    TaskControl.Logger.LogError("Not a valid JS script project: {Message}", ex.Message);
}

Prevention

When it happens

Trigger: Constructing new ScriptProject(folderName) where the directory exists but Path.Combine(ProjectPath, 'manifest.json') does not. The folder might be a different script type (Pathing JSON, KeyMouse) or an incomplete JS project.

Common situations: A ScriptGroupProject of Type 'Javascript' points to a folder that is actually a Pathing or KeyMouse script folder. The manifest.json was deleted or never created. The folder was created but the script was never fully set up. Confusing script types in configuration.

Related errors


AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13). Data as JSON: /api/errors/6b690d53e1f90ce9. Report an issue: GitHub.