简体   繁体   中英

NPM error TS2304: Cannot find name 'VRDisplay' for ThreeJS

The errors are below.

ERROR in node_modules/@types/three/three-core.d.ts(7800,18): error TS2304: Cannot find name 'VRDisplay'.
node_modules/@types/three/three-core.d.ts(7801,23): error TS2304: Cannot find name 'VRDisplay'.
node_modules/@types/three/three-vrcontrols.d.ts(15,27): error TS2304: Cannot find name 'VRDisplay'.
node_modules/@types/three/three-vreffect.d.ts(20,27): error TS2304: Cannot find name 'VRDisplay'.

I've tried all sorts of changes to the tsconfig.json file and checking to make sure the npm installs were fine. Some minor versions differ with other servers that have the same package.json, but nothing that should break this.

Why might this issue be coming up?

Should note, we use node 6.12.10 and npm 3.10.10 because of reasons out of my power.

Actually VRDisplay is not a class of three.js but a web interface of the WebVR API. npm install --save @types/webvr-api worked for me.

In addition to Belane's answer, I had to import the weber-api somewhere (before importing three?):

import { VRDisplay } from 'webvr-api';

EDIT: this worked in live reloading "ionic serve", but it blows up "ionic build"... Gave up and changed "VRDisplay" to "any" in @types/three.

Getting error?

Cannot find name 'VRDisplay'.

It's just a typescript version. You need to update typescript version please find below command. npm install typescript@2.8.1

Working fine without any errors.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM