huiyadanli/RevokeMsgPatcher · error · Exception

在路径{appPath}下,未找到package.json文件

Error message

在路径{appPath}下,未找到package.json文件

What it means

ModifyPackageJson(appPath) edits <appPath>/package.json (backing it up first, then rewriting the main field). If package.json is absent it throws a plain Exception, because appPath did not resolve to QQNT's real app directory.

Source

Thrown at RevokeMsgPatcher/Forms/FormLiteLoaderQQNT.cs:397

                    var s = (string)jsonObj.main;
                    if (s.Contains("liteloader.h.js"))
                    {
                        Debug.WriteLine("已经修改过package.json文件");
                        return;
                    }
                }

                // 备份
                File.Copy(packageJsonPath, Path.Combine(appPath, "package.json.h.bak"), true);

                // 修改
                jsonObj.main = "./app_launcher/liteloader.h.js";
                string output = JsonConvert.SerializeObject(jsonObj, Formatting.Indented);
                File.WriteAllText(packageJsonPath, output);
            }
            else
            {
                throw new Exception($"在路径{appPath}下,未找到package.json文件");
            }
        }

        private void btnChoose_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog();
            dialog.Description = "请选择安装路径";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                if (string.IsNullOrEmpty(dialog.SelectedPath) || !IsAllFilesExist(dialog.SelectedPath))
                {
                    MessageBox.Show("无法找到此应用的关键文件,请选择正确的安装路径!");
                }
                else
                {
                    txtQQNTPath.Text = dialog.SelectedPath;
                }
            }

View on GitHub (pinned to 89cbbb3f0c)

Solutions

  1. Verify the QQNT install path (must contain QQ.exe).
  2. Ensure versions\<ver>\resources\app\package.json actually exists.
  3. Reinstall QQNT to repair the app folder if it is corrupted.
Defensive patterns

Strategy: validation

Validate before calling

string packageJsonPath = Path.Combine(appPath, "package.json");
if (!File.Exists(packageJsonPath))
{
    MessageBox.Show($"{appPath} 下未找到 package.json,请确认安装路径是否正确。");
    return;
}
ModifyPackageJson(appPath);

Prevention

When it happens

Trigger: appPath lacks package.json. Happens when the install path is wrong, when GetAppPath fell through to <install>/resources/app (because the versions folder was missing/empty) where no package.json exists, or when the app directory is corrupted.

Common situations: Wrong folder chosen (not the QQNT root); QQNT installed in a non-standard layout; versions folder exists but holds no version subdir.

Related errors


AI-assisted analysis of huiyadanli/RevokeMsgPatcher@89cbbb3f0c (2026-08-13). Data as JSON: /api/errors/43de635f8f8d3c4e. Report an issue: GitHub.