Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue running javascript library (photo sphere viewer)

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

like image 782
user3257598 Avatar asked Jun 13 '17 10:06

user3257598


1 Answers

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
like image 61
Yes Barry Avatar answered Nov 15 '22 00:11

Yes Barry