ayda-tech / react-share-kit

React-Share-Kit is an easy-to-use library that adds social media share buttons to React and Next apps for popular platforms like Facebook, Twitter, and LinkedIn.
https://react-share-kit.vercel.app/
MIT License
13 stars 1 forks source link

index.js is treated as an ES module file as it is a .js file #16

Open Dev-Akash opened 8 months ago

Dev-Akash commented 8 months ago

ReferenceError: require is not defined in ES module scope, you can use import instead

This file is being treated as an ES module because it has a '.js' file extension and '/vercel/path0/node_modules/react-share-kit/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.

So this is the error coming while implementing in next js application. On my local have removed the "type": "module " line from package.json

Please let me know if this can be resolved as on deploying it is giving issue.

Thank you!

ybhrdwj commented 7 months ago

I was facing same issue, resolved by the following way: added /dist/index.js in the import statement 'react-share-kit/dist/index.es'

kaybrian commented 6 months ago
khayargoli commented 5 months ago

I still have this issue in my next.js 14 application, any solution?