简体   繁体   English

NPM错误TS2304:找不到ThreeJS的名称'VRDisplay'

[英]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. 我已经尝试了对tsconfig.json文件的各种更改,并检查以确保npm安装没问题。 Some minor versions differ with other servers that have the same package.json, but nothing that should break this. 一些次要版本与具有相同package.json的其他服务器不同,但没有什么可以打破这个。

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. 应该注意,我们使用节点6.12.10和npm 3.10.10,因为我的权力不足。

Actually VRDisplay is not a class of three.js but a web interface of the WebVR API. 实际上VRDisplay不是一个three.js类,而是WebVR API的Web界面。 npm install --save @types/webvr-api worked for me. npm install --save @types/webvr-api为我工作。

In addition to Belane's answer, I had to import the weber-api somewhere (before importing three?): 除了Belane的回答之外,我还必须在某处导入weber-api (在导入三个之前?):

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. 编辑:这在实时重新加载“离子服务”,但它炸毁了“离子构建”......放弃并将“VRDisplay”更改为@ types / 3中的“any”。

Getting error? 得到错误?

Cannot find name 'VRDisplay'. 找不到名字'VRDisplay'。

It's just a typescript version. 它只是一个打字稿版本。 You need to update typescript version please find below command. 您需要更新typescript版本,请在下面找到命令。 npm install typescript@2.8.1 npm install typescript@2.8.1

Working fine without any errors. 工作正常,没有任何错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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