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

Error when try to use your component in Nextjs: Cannot find module 'tsup-tutorial/Button' or its corresponding type declarations. #2

Open
Jared-Dahlke opened this issue Sep 21, 2023 · 5 comments

Comments

@Jared-Dahlke
Copy link

i am trying to use the button component in your library.

it works fine with Vite, but with Nextjs I cannot build because i get this error:
Cannot find module 'tsup-tutorial2/Button' or its corresponding type declarations.

Any idea why this may be?

@officialrajdeepsingh
Copy link
Owner

You are not importing the package correctly. The correct ways.

tsup-tutorial/Button

@Jared-Dahlke
Copy link
Author

Jared-Dahlke commented Sep 23, 2023 via email

@officialrajdeepsingh
Copy link
Owner

officialrajdeepsingh commented Sep 23, 2023

Nope. If you try to use I think next 13.2 or younger it won’t work because they have moduleResolution:node instead of bundled

Yes, I've also found the same issue. Due to my busy schedule, I can not find the actual cause of the problem and also can't find a solution.

@preshonyee
Copy link

@Jared-Dahlke I'm having the same error. What was the fix for this?

@Jared-Dahlke
Copy link
Author

Jared-Dahlke commented Sep 23, 2023

I found a solution.

for some reason you have to specify the exact path in package.json. So you have to have 2 exports per component. One for node and one for bundler

image

And you have to import it from "/dist/button"

But again if you can just get your consumers to change to bundler in their config then you don't have to do any of this it just works

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

3 participants