react-file-type-icons / react-file-type-icons

Includes file-type Icons
MIT License
2 stars 1 forks source link

SSR issue, Cannot use import statement outside a module #3

Open geniuscd opened 2 years ago

geniuscd commented 2 years ago

Hello Great Plugin! thanks for the hard work. i guess its broken when using it in NextJS (SSR) it's giving the below

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:1053:16)
    at Module._compile (internal/modules/cjs/loader.js:1101:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.react-file-type-icons ({the porject folder}\.next\server\pages\clients\[id]\deals\[deal_id].js:10671:18)
    at __webpack_require__ ({the porject folder}\.next\server\webpack-runtime.js:25:42)
    at Object../src/components/FilesGridItem.js ({the porject folder}\.next\server\pages\clients\[id]\deals\[deal_id].js:9929:79)
{the porject folder}\node_modules\react-file-type-icons\index.js:1
import GenIcon from "./icons/GenIcon";
^^^^^^

When i use it without refreshing the page, it works, but after hitting the refresh button, its giving the error.

geniuscd commented 2 years ago

i guess u should import GenIcon from "./GenIcon"; instead of import GenIcon from "./icons/GenIcon";

riteshreg commented 1 year ago

index.js?46cb:598 Uncaught SyntaxError: Cannot use import statement outside a module I am trying to use this library on nextjs application