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 'react-day-picker/dist/style.css' #2516

Closed
shareef-dweikat opened this issue Oct 7, 2024 · 6 comments
Closed
Labels
cannot reproduce package Issues related to the npm package and commonjs support

Comments

@shareef-dweikat
Copy link

shareef-dweikat commented Oct 7, 2024

Hi,

import {
  DayPicker,
  DateRange,
  ClassNames,
  DayPickerRangeProps,
  DayPickerSingleProps,
} from 'react-day-picker';
import 'react-day-picker/dist/style.css';

I also have tried
import styles from 'react-day-picker/dist/style.module.css';

Actual Behavior

The build fails due to "Unable to resolve path to module 'react-day-picker/dist/style.css'" error

Version "react-day-picker": "^9.1.3"

@karlshea
Copy link
Contributor

karlshea commented Oct 7, 2024

I had similar issues importing into a Sass stylesheet, there are multiple style exports in the package.json and they're not resolving. When I finally did get one to resolve there was an additional error because the "default" key isn't last ("types" is getting added after it).

I finally got it to work by using @use instead of @import and using a relative path to the source in node_modules.

@shareef-dweikat
Copy link
Author

@karlshea Thanks
My case might be a little different. I am trying to import it into tsx file, not a Sass.
Your solution wont work for me.

@gpbl
Copy link
Owner

gpbl commented Oct 15, 2024

👋 The correct path for the style is either react-day-picker/style.css or react-day-picker/style.module.css.

If you're really having issues importing these, the source file is located at react-day-picker/src/style.css (in the /src directory).

PS. In v9.1.4, we addressed some compatibility issues with older build systems—could you please give it a test? Thanks!

See also #2521.

@gpbl gpbl added package Issues related to the npm package and commonjs support cannot reproduce labels Oct 15, 2024
@shareef-dweikat
Copy link
Author

@gpbl Thanks

Importing from the source directly is not working (Unable to resolve path to module 'react-day-picker/src/style.css')
I have upgraded to v9.1.4, i get same errors.

I am using create-react-app

@gpbl
Copy link
Owner

gpbl commented Oct 15, 2024

@shareef-dweikat The import path is react-day-picker/style.css.

I don’t have any issues importing it using create-react-app. If you believe this is a bug in DayPicker, please reproduce the bug on stackblitz.com or codesandbox.io and open a support discussion. Thanks!

@gpbl gpbl closed this as completed Oct 15, 2024
@karlshea
Copy link
Contributor

It's still not working using sass-loader and webpack, follow up here: #2546

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cannot reproduce package Issues related to the npm package and commonjs support
Projects
None yet
Development

No branches or pull requests

3 participants