V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
magicdu
V2EX  ›  问与答

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

  •  
  •   magicdu · Apr 22, 2021 · 1087 views
    This topic created in 1843 days ago, the information mentioned may be changed or developed.

    自己开发的 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 replies    2021-04-22 14:28:40 +08:00
    oott123
        1
    oott123  
       Apr 22, 2021
    注册完之后 cwd 不对了
    用 __dirname 会好一点
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3130 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 03:15 · PVG 11:15 · LAX 20:15 · JFK 23:15
    ♥ Do have faith in what you're doing.