babalae/better-genshin-impact · error · FileNotFoundException
main js file not found.
Error message
main js file not found.
What it means
Thrown by Manifest.Validate when the main JS file specified in manifest.json does not exist on disk at Path.Combine(path, Main). This is a FileNotFoundException — the manifest passed all field validation but the referenced entry-point file is missing from the project directory.
Source
Thrown at BetterGenshinImpact/Core/Script/Project/Manifest.cs:56
{
if (string.IsNullOrWhiteSpace(Name))
{
throw new Exception("manifest.json: name is required.");
}
if (string.IsNullOrWhiteSpace(Version))
{
throw new Exception("manifest.json: version is required.");
}
if (string.IsNullOrWhiteSpace(Main))
{
throw new Exception("manifest.json: main script is required.");
}
if (!File.Exists(Path.Combine(path, Main)))
{
throw new FileNotFoundException("main js file not found.");
}
// 比较版本号大小 BgiVersion
if (!string.IsNullOrWhiteSpace(BgiVersion) && Global.IsNewVersion(BgiVersion))
{
TaskControl.Logger.LogError("脚本 {Name} 版本号要求 {BgiVersion} 大于当前 BetterGI 版本号 {CurrentVersion} , 脚本可能无法正常工作,请更新 BetterGI 版本!", Name, BgiVersion, Global.Version);
}
}
public List<SettingItem> LoadSettingItems(string path)
{
if (string.IsNullOrWhiteSpace(SettingsUi))
{
return [];
}
var settingItems = new List<SettingItem>();
var settingFile = Path.Combine(path, SettingsUi);View on GitHub (pinned to a7cb36712d)
Solutions
- Check that the file specified in manifest.json's 'main' field exists in the script folder.
- Verify the filename spelling, case, and extension match exactly.
- If the file was renamed, update manifest.json's 'main' field to match.
- Re-download or re-extract the script package if files are missing.
Example fix
// manifest.json: "main": "index.js" but file is main.js // before "main": "index.js" // after "main": "main.js"
Defensive patterns
Strategy: validation
Validate before calling
var mainFile = Path.Combine(projectPath, manifest.Main);
if (!File.Exists(mainFile))
throw new FileNotFoundException($"Main JS file not found: {mainFile}"); Try / catch
try
{
manifest.Validate(projectPath);
}
catch (FileNotFoundException ex) when (ex.Message.Contains("main js file not found"))
{
TaskControl.Logger.LogError("Entry-point JS file missing for script");
} Prevention
- Verify the main JS file exists after creating or downloading a script package.
- Check filename case sensitivity, especially on Linux.
- Ensure the 'main' field in manifest.json exactly matches the file on disk.
When it happens
Trigger: Manifest.Validate(path) is called after deserialization. The Main field is non-empty (passed the previous check), but File.Exists(Path.Combine(projectPath, main)) returns false. The main JS file was deleted, renamed, or the path is wrong.
Common situations: The main.js file was accidentally deleted or renamed. The manifest's 'main' field points to the wrong filename (typo, wrong extension, wrong path). A script package was incompletely extracted/downloaded. Case-sensitivity mismatch on Linux (Main.js vs main.js).
Related errors
- manifest.json: name is required.
- manifest.json: version is required.
- manifest.json: main script is required.
- manifest.json文件不存在,请确认此脚本是JS脚本类型。{ManifestFile}
- Failed to deserialize JSON.
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/3815d5c4dbdd65b0.
Report an issue: GitHub.