Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module error #85

Closed
joaobzrr opened this issue Dec 14, 2022 · 7 comments
Closed

Cannot find module error #85

joaobzrr opened this issue Dec 14, 2022 · 7 comments

Comments

@joaobzrr
Copy link

joaobzrr commented Dec 14, 2022

Hi,

For some reason all the imports in the README fail.

// All of the following give "Cannot find module..." error
import { createIPCHandler } from "electron-trpc/main";
import { exposeElectronTRPC } from "electron-trpc/main";
import { ipcLink } from "electron-trpc/renderer";

Importing from /dist or /src compiles, but fails at runtime with the same error.

I'm using version 0.2.1 of electron-trpc.

@jsonnull
Copy link
Owner

Hey, thanks for raising the issue.

What tooling is giving you the error? TypeScript? Eslint? A packager?

Please note that the exposeElectronTRPC import is from electron-trpc/main, as the current GitHub README shows.

@joaobzrr
Copy link
Author

What tooling is giving you the error? TypeScript? Eslint? A packager?

Not sure. I'm using the electron-react-webpack-typescript-2022 template and I'm simply running npm run start. Guess it's Typescript?

Please note that the exposeElectronTRPC import is from electron-trpc/main, as the current GitHub README shows.

Sorry, that was a typo. Fixed it now.

@joaobzrr
Copy link
Author

Here's what node_modules/electron-trpc/ looks like:

│   LICENSE
│   package.json
│
├───dist
│       main.cjs
│       main.d.ts
│       main.mjs
│       renderer.cjs
│       renderer.d.ts
│       renderer.mjs
│
└───src
    │   constants.ts
    │   types.ts
    │
    ├───main
    │   │   createIPCHandler.ts
    │   │   exposeElectronTRPC.ts
    │   │   index.ts
    │   │   resolveIPCResponse.ts
    │   │   utils.ts
    │   │   vite.config.ts
    │   │
    │   └───__tests__
    │           resolveIPCResponse.test.ts
    │
    └───renderer
            index.ts
            ipcLink.ts
            tsconfig.json
            utils.ts
            vite.config.ts

@jsonnull
Copy link
Owner

Can you try changing moduleResolution in tsconfig.json from node to node16?

@joaobzrr
Copy link
Author

That fixed it. Thanks!

@jsonnull
Copy link
Owner

Thanks for bringing this to my attention.

I learned recently that there's a backwards compatible solution I can implement in this package that wouldn't require that node16 change. There's almost no downsides for me.

I aim to make that change soon, that should prevent this issue from occurring again and you'll be able to go back to using node module resolution if it benefits you.

@jsonnull
Copy link
Owner

This is fixed in electron-trpc@0.3.2 in case you want to continue using node module resolution in TS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants