desmos-labs / desmjs

SDK to create dapp that interact with the Desmos blockchain
Apache License 2.0
8 stars 6 forks source link

Cannot find module '@desmoslabs/desmjs' or its corresponding type declarations in Next.js project within DesmJS monorepo #1138

Open sundayonah opened 2 months ago

sundayonah commented 2 months ago

Hello,

I'm currently working on a Next.js project named next-walletconnect-example which is located inside the DesmJS monorepo. I've encountered an issue where TypeScript cannot find the module @desmoslabs/desmjs or its corresponding type declarations. Specifically, it fails to resolve the path to @desmoslabs/desmjs-types/desmos/profiles/v3/models_profile.

Here are the details of my setup:

Next.js Project (next-walletconnect-example): package.json dependencies include @desmoslabs/desmjs and @desmoslabs/desmjs-types with the workspace: prefix pointing to the local packages within the monorepo.

DesmJS Monorepo (desmjs-monorepo-root):Contains the workspaces configuration in its package.json, listing all the packages and examples within the monorepo. Local packages @desmoslabs/desmjs and @desmoslabs/desmjs-types are defined with paths relative to the monorepo root.

I have run yarn install both in the root folder and inside the next-connect-wallet folder which comprises of the nextjs project. I've attempted to resolve this issue by adjusting the baseUrl and adding a paths configuration in my tsconfig.json within the Next.js project. However, the problem persists. Could anyone provide guidance on how to correctly configure TypeScript to resolve these local modules within our monorepo setup? Any insights or solutions would be greatly appreciated.

Thank you!

dadamu commented 2 months ago

Hi, @sundayonah, sorry for the late reply.

In development mode, it works in typescript so yarn && yarn dev should work properly as well. To get better DX you can try yarn && yarn build in the root path first. This issue is because IDE couldn't get the built library from packages.

yarn && yarn build # in the root path
cd examples/next-walletconnect-example

Please restart IDE after yarn build as IDE might not update immediately for the build path.