Elius94 / react-photo-sphere-viewer

Photosphere Viewer for React.JS
MIT License
69 stars 21 forks source link

SyntaxError: Cannot use import statement outside a module #16

Closed Otimkev closed 1 year ago

Otimkev commented 1 year ago

`import { assign, spreadArray } from './node_modules/tslib/tslib.es6.js'; ^^^^^^

SyntaxError: Cannot use import statement outside a module at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1032:15) at Module._compile (node:internal/modules/cjs/loader:1067:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18)`

I get the above error in a Nextjs project.

Elius94 commented 1 year ago

Hello @Otimkev As written in the readme, if you use Next.js you have to import the project in this way:

// import { ReactPhotoSphereViewer } from 'react-photo-sphere-viewer'; const ReactPhotoSphereViewer = dynamic( () => import('react-photo-sphere-viewer').then( (mod) => mod.ReactPhotoSphereViewer ), { ssr: false, } );

export default function Home() {
return (

); }



I suppose that the trouble is caused by this. 
If you have any troubles, feel free to open the issue again.
Thanks.