quirky purple
quirky purple

Reputation: 2219

Electron setAsDefaultClientProtocol Unable to compile TypeScript when app is redirected to

I'm attempting to register a protocol to my electron application. My application is fork based on electron-react-boilerplate. I'm attempting to integrate Azure OAuth into my application and have been following MSAL's ElectronSystemBrowserTestApp example. I am successful in opening the authentication window in the browser, which returns the authorization response code which is then intercepted by the CustomLoopbackClient, caches the token, opens the browser to a success template that then redirects to my custom protocol via a script. This is all exemplified in the ElectronSystemBrowserTestApp code. However, at this step electron throws the following error:

enter image description here

My code to register my custom protocol is located in my main.ts file, and is as follows:

Main.application.setAsDefaultProtocolClient(
      authConfig.customProtocol.name,
      process.execPath,
      [
        '-r',
        path.join(
          __dirname,
          '..',
          '..',
          'node_modules',
          'ts-node/register/transpile-only',
        ),
        path.join(__dirname, './app.ts'),
      ],
    );

Given my following file structure, the above paths should resolve successfully.

node_modules
src
    main
    |    app.ts
    |    main.ts

I have confirmed that ts-node/register/transpile-only is present.

I can't find much information on what the third argument here should contain, but in examples I've seen in the few issue threads I can find about this, I gather it should be a path to node-ts transpile-only.js and a path to your app main process entry file. In accordance with the message I've attempted to set my tsconfig.json file's module and moduleResolution to NodeNext, but it still emits the same error.

Upvotes: 0

Views: 60

Answers (0)

Related Questions