JSX Runtime.
Hi I am getting the following error inside a typescript project.
Error:
ERROR in ./node_modules/react-sticky-box/dist/index.js 3:0-40 Module not found: Error: Can't resolve 'react/jsx-runtime' in '../node_modules/react-sticky-box/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.
I am using a sample from the demo site:
import StickyBox from "react-sticky-box"; <StickyBox offsetTop={90} offsetBottom={90}><div>Test</div></StickyBox>
In the file:
node_modules/react-sticky-box/dist/index.js
If I change this line
import { jsx } from "react/jsx-runtime";
To:
import { jsx } from "react/jsx-runtime.js";
Everything works. Obviously this is not ideal.
+1 having the same issue
What bundling system do you use? Vite? Webpack?
I am using Webpack.
@danielberndt I am using Nextjs 12 webpack 5
I've just released v2.0.2 which should fix this issue
i upgraded to the new version but still get same error deploying to vercel
downgrading to 2.0.0 worked for me
Yes had to release 2.0.3 to roll back the changes as it was breaking our internal build system as well. Not really sure what exactly to do from here. I was really not expecting that esm would be that complicated for such a simple setup with a single file and pretty much zero dependencies. 😅
if you are using next.js , just do dynamic import with ssr disabled.
const StickyBox = dynamic(() => import('react-sticky-box'), {
ssr: false,
});
this doesn't work for me.
Hi! Is there any solution to the problem? I'm getting a similar error with Webpack. I tried different versions 2.0.0 - 2.0.5, it didn’t help.
upd. Downgrading to 1.0.2 helped.