react-datepicker icon indicating copy to clipboard operation
react-datepicker copied to clipboard

Package path ./dist/react-datepicker.css is not exported from package

Open maiconfluency opened this issue 10 months ago • 9 comments

"react-datepicker": "^8.1.0",

Image

maiconfluency avatar Feb 20 '25 14:02 maiconfluency

Hi @maiconfluency ,

I couldn't able to reproduce the mentioned issue. I tried installing the recent version (v 8.1.0) of the package and it's working fine for me. Can you try uninstalling and reinstalling the package.

Image

balajis-qb avatar Feb 24 '25 12:02 balajis-qb

I am facing this issue also

oh-dev-life avatar Feb 25 '25 16:02 oh-dev-life

Have the same with Next v12 The problem is that it does not recognize wildcard in react-datepicker's package.json exports field. My guess is that Next is old, and probably either Webpack itself is also old or Webpack's default configuration has that issue.

For now, I've solved by copying react-datepicker.css to my project and importing locally.

Karabur avatar Feb 25 '25 23:02 Karabur

Have the same with Next v12 The problem is that it does not recognize wildcard in react-datepicker's package.json exports field. My guess is that Next is old, and probably either Webpack itself is also old or Webpack's default configuration has that issue.

For now, I've solved by copying react-datepicker.css to my project and importing locally.

i have the same problem but with next v11. Now I am using react-datepicker v5. It is not possible to build with v7.

maiconfluency avatar Feb 26 '25 04:02 maiconfluency

+1

OwnerOfThisIsle avatar Feb 28 '25 11:02 OwnerOfThisIsle

+1

ludovers avatar Mar 28 '25 15:03 ludovers

+1

Anvarmirzo avatar Apr 13 '25 21:04 Anvarmirzo

+1 React 18.3.1

likeuwill avatar Apr 17 '25 14:04 likeuwill

Same problem with Next v12

muhib-dev avatar May 14 '25 04:05 muhib-dev

+1 React 19

Same problem with Yarn 4.x

Issue might be that Yarn PnP does not yet support wildcards properly in module exports? Or might have to do with webpack css-loader.

 {                                                                    
   "exports": {                                                       
     ".": { /* main entry */ },                                       
     "./dist/*.css": "./dist/*.css",                                  
     "./src/stylesheets/*.scss": "./src/stylesheets/*.scss"           
   }                                                                  
 }                   

I think for this to work on Yarn PnP, they would need to provide explicit exports.

ex.

 {                                                                                    
   "exports": {                                                                       
     "./dist/react-datepicker.css": "./dist/react-datepicker.css",                    
     "./dist/react-datepicker.min.css": "./dist/react-datepicker.min.css",            
     "./dist/react-datepicker.module.css": "./dist/react-datepicker.module.css"       
   }                                                                                  
 }                 

Ethorsen avatar Sep 10 '25 18:09 Ethorsen

I'm having the same problem after updating Storybook. I'm using npm. More details at: https://github.com/Hacker0x01/react-datepicker/issues/5835

Aluisio avatar Sep 11 '25 12:09 Aluisio

This seems to have been introduced with 8.0.0 with the addition of the exports property in package.json. I'm using [email protected] (via craco/[email protected]) and have tried in the current and previous 4 Node.js LTS releases. Others on this thread mention using Next.js 12, which is locked to [email protected] (found through much digging) at the last release (Next.js v12.3.7). So the cultprit here is webpack 5 which introduced stricter enforcement of exports but was not without problems.

In Webpack 5.94 there was some major correction to its export processing:

As of version 5.94.0, webpack's behavior has been updated to align with Node's behavior. It now selects the first valid path without attempting further resolutions and throws an error if the path cannot be resolved. (source)

So us using Next.js 12 or CRACO/react-scripts are a bit SOL as we are locked to explicit Webpack versions.

Workarounds:

  • If you're capable of updating Webpack (Next.js 12 and CRACO/react-scripts users are not), upgrade to anything Webpack >=5.94.0 will use the latest resolves which have been written in parity with Node.js' path resolution.
  • Rollback to [email protected]
  • I've got a fork and branch with a patched package.json and included a built ./dist which should mimic the 8.9.0 distribution
    • npm install -S github:robtayl0r/react-datepicker#fix/5437-broken-css-imports-dist
    • (source)

Opening a PR with the change as well.

robtayl0r avatar Nov 12 '25 22:11 robtayl0r

With the PR merged, is this fixed?

martijnrusschen avatar Nov 27 '25 10:11 martijnrusschen