Issue running javascript library (photo sphere viewer)

1.1k views Asked by At

I wanted to use Photo Sphere Viewer in my project. So I ran

npm i photo-sphere-viewer

It appears to have downloaded the modules.

Then inside my project I did:

import PhotoSphereViewer from 'photo-sphere-viewer/dist/photo-sphere-viewer';

But I get error:

Failed to compile.

Error in ./~/photo-sphere-viewer/dist/photo-sphere-viewer.js
Module not found: 'D.js' in /home/ghy/WebstormProjects/mia-map/node_modules/photo-sphere-viewer/dist

 @ ./~/photo-sphere-viewer/dist/photo-sphere-viewer.js 9:4-55

Can anyone help me spot what is wrong?

PS. I think following line is causing issue (inside photo-sphere-viewer.js):

  if (typeof define === 'function' && define.amd) {
    define(['three', 'D.js', 'uevent', 'doT'], factory);
  }

but I am even surprised why it enters inside this if as I didn't know I had require.js installed.

PPS. I have a react application created by create-react-app

1

There are 1 answers

0
Yes Barry On

Mine works with webpack using:

import { Viewer } from 'photo-sphere-viewer';

const viewer = new Viewer({
    container: document.querySelector('#viewer'),
    panorama: 'path/to/photo.jpg'
});

You can install with npm or yarn

npm install photo-sphere-viewer
# or
yarn add photo-sphere-viewer