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

Unable to resolve path to module 'export-to-csv' #108

Closed
markhats opened this issue Jun 10, 2024 · 11 comments
Closed

Unable to resolve path to module 'export-to-csv' #108

markhats opened this issue Jun 10, 2024 · 11 comments

Comments

@markhats
Copy link

When trying to import export-to-csv into a js create-react-app via

import { mkConfig, generateCsv, download } from 'export-to-csv';

I'm getting the following linter warning.

Unable to resolve path to module 'export-to-csv'

I then get a similar error when building the production version of the app and it fails to build.

Any ideas what might be causing this?

Thanks.

@alexcaza
Copy link
Owner

alexcaza commented Jun 15, 2024

Just commenting to say I see this, and I'll attempt a reduced test case when I can. Life has been more busy lately :)

In the meantime, If you could replicate it in a stackblitz, or a github repo I could clone, to make the process quicker, that would be excellent! 😄

@alexcaza
Copy link
Owner

I took some time to spin up an app using create-react-app v5.0.1, and I don't have the same error. If you could create a reduced test case, that would be great.

Here's the repo: https://github.com/alexcaza/cra-test-export-to-csv

If I don't hear back within the next week, I'm going to close the issue as resolved 😄

@markhats
Copy link
Author

Sorry - I haven't had a chance to create a simple test case that exhibits the issue.

It seems that it is actually really just a linter error and can be disabled using the following on the line above the import:

// eslint-disable-next-line import/no-unresolved
import { mkConfig, generateCsv, download } from 'export-to-csv';

I've no idea why it is only the export-to-csv import causing this though.

@alexcaza
Copy link
Owner

alexcaza commented Jun 17, 2024

If that works, and you're comfortable running with that, then great 😄 If you want further help, a basic repo with a stripped-down version of your project would be helpful! I suspect it's a project config-related issue, though.

I'll leave this issue open for a while longer (until mid-July) if you have time to come back to it.

For clarity's sake, a stripped-down repo would contain a package.json with versions locked to the same versions in your main project, config files set up as you have them in your main project and only the bare components or functionality you're trying to test!

@ajanauskas
Copy link

I also encountered same issue

@alexcaza
Copy link
Owner

I also encountered same issue

@ajanauskas would you have a reduced test case you could share? Like I said above I'm not able to replicate, and I suspect it's a config issue but I can't confirm that without more details 😄

@ajanauskas
Copy link

would be happy to if I understood whats causing this. My codebase is pretty big, lots of dependencies with most of them being private so its not that easy to replicate it

@alexcaza
Copy link
Owner

It's possible it's related to this thread.

If it's an older project it might have to do with this package being an ES module, which won't natively work with commonjs projects.

I'd also recommend looking at this gist to see if maybe there are things you can change in your bundler/environment if it is in fact related to it being an es module.

@Yousif-FJ
Copy link

Yousif-FJ commented Jun 25, 2024

I fixed the issue by updating the typescript package version in my project.

@alexcaza
Copy link
Owner

We've hit the mid-July mark for this issue. I'm going to close it for now since no one seems to be able to give a reduced test case for it. Feel free to open a new issue with one if it doesn't get resolved.

@alexcaza alexcaza closed this as not planned Won't fix, can't repro, duplicate, stale Jul 18, 2024
@ZengLawrence
Copy link

I had same issue. Was able to fix by upgrading typescript to 5.6.3.

Looked like it was caused by transcomplie issue rather than support for ESM.

Lastly, this gist posted above really helped explain all error scenarios.

@alexcaza, thank you for maintaining this package.

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

5 participants