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

调试Node.js时DLOPEN错误排查求助:VS2022报错终端运行正常

问题描述

编程新手在Visual Studio 2022中调试Node.js应用时遇到DLOPEN错误,提示找不到模块\\?\C:\Users\QSUser\choco-gui\node_modules\@nodegui\nodegui\build\Release\nodegui_core.node。已尝试npm update、删除并重建node_modules文件夹,但问题未解决。不过在项目目录通过终端执行npm start时程序可正常运行,需排查该错误的方法。

错误信息

node:internal/modules/cjs/loader:1210
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: The specified module could not be found.
\\?\C:\Users\QSUser\choco-gui\node_modules\@nodegui\nodegui\build\Release\nodegui_core.node
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1210:18)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
 >  at Object.<anonymous> (C:\Users\QSUser\choco-gui\node_modules\@nodegui\nodegui\dist\lib\utils\addon.js:3:15)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12) {
  code: 'ERR_DLOPEN_FAILED'
}

C:\Users\QSUser\choco-gui\src\src.exe (process 17392) exited with code 1.

排查解决方法

  • 检查VS2022调试的Node.js版本:确认调试配置中使用的Node版本与终端npm start用的版本一致。打开调试配置文件(.vscode/launch.json),查看runtimeExecutable指向的路径,和终端执行node -v显示的版本路径匹配。
  • 重新编译NodeGUI原生模块:执行npm rebuild @nodegui/nodegui --force,手动触发原生模块编译,因为VS调试环境可能未自动完成编译步骤。
  • 验证模块文件存在:直接访问路径C:\Users\QSUser\choco-gui\node_modules\@nodegui\nodegui\build\Release\,确认nodegui_core.node文件是否存在。如果不存在,重新执行编译命令。
  • 修正VS调试工作目录:在调试配置中设置cwd为项目根目录(即包含package.json的文件夹),避免模块路径解析错误。
  • 安装Windows构建工具:以管理员权限运行终端,执行npm install --global windows-build-tools,确保编译原生模块所需的环境完整。
  • 关闭VS调试隔离:在调试配置的高级选项中,禁用"启用隔离进程",避免沙盒限制文件访问。
  • 清理npm缓存:执行npm cache clean --force,然后重新执行npm install,排除缓存损坏的影响。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.19 03:15:32