nygardk / react-share

Social media share buttons and share counts for React
MIT License
2.6k stars 429 forks source link

Module not found: Error: Can't resolve 'react/jsx-runtime' in 'node_modules/react-share/dist' #517

Open himavan opened 7 months ago

himavan commented 7 months ago

Hey the following is the error

Module not found: Error: Can't resolve 'react/jsx-runtime' in '/node_modules/react-share/dist'
Did you mean 'jsx-runtime.js'?
BREAKING CHANGE: The request 'react/jsx-runtime' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
nygardk commented 7 months ago

Hello! Are you on React 18?

himavan commented 7 months ago

Hey! I'm react 17.0.2

mmacarth commented 7 months ago

Hello, we have the same issue. On 17.0.2 as well. It seems to only happen when running on Windows, not on Mac or Ubuntu.

mmacarth commented 7 months ago

For others, fyi. We use webpack and we'd solved the issue by adding the following rule:

           {
              test: /\.js$/,
              include: /node_modules\/react-share/,
              resolve: {
                fullySpecified: false,
              },
            },

This matches .js files in node_modules/react-share and sets fullySpecified to false as there's no extension on the import from jsx-runtime in react-share.

On windows, the include regex wasn't working as it includes a "/". Instead using:

     include: path.resolve('node_modules', 'react-share'),

does match the windows formatting for path and the build succeeds.

loishobe commented 5 months ago

Hello is there any workaround or fix for this?

monecchi commented 4 months ago

So sad :( Moving to other library until this is solved...

sudhanshutech commented 3 months ago

same happening for us

zachandblue commented 1 month ago

bummer