V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
magicdu
V2EX  ›  问与答

浏览器里打开自己开 electron 客户端的问题,报 Cannot open resources\xxx.node: Error: The specified module could not be found.

  •  
  •   magicdu · 2021-04-22 13:38:43 +08:00 · 691 次点击
    这是一个创建于 1113 天前的主题,其中的信息可能已经有所发展或是发生改变。

    自己开发的 electron 客户端,用了 native-ext-loader 加载器

    rewritePath: param.TRTC_ENV === 'production'
                  ? param.TARGET_PLATFORM === 'win32' ? './resources' : '../Resources'
                  : './node_modules/xxx-sdk/build/Release'
    

    客户端打包完安装上可以打开,但是通过自定义注册表 app.setAsDefaultProtocolClient("myapp") ,从浏览器打开客户端(myapp://),客户端就报错

    pic

    只有把路径写死才可以

    rewritePath: os.platform() === 'win32' ? 'C:/Program Files/myapp/resources' : '../Resources' 
    
    1 条回复    2021-04-22 14:28:40 +08:00
    oott123
        1
    oott123  
       2021-04-22 14:28:40 +08:00
    注册完之后 cwd 不对了
    用 __dirname 会好一点
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1380 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 23:40 · PVG 07:40 · LAX 16:40 · JFK 19:40
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.