Angular 5,三Js错误

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Angular 5,三Js错误相关的知识,希望对你有一定的参考价值。

一些路径配置错误我无法解决这个问题。这是我的移民。 “@ angular / animations”:“^ 5.1.1”,“@ angular / cdk”:“^ 5.0.1”,“@ angular / common”:“^ 5.0.0”,“@ angular / compiler”:“ ^ 5.0.0“,”@ angular / core“:”^ 5.0.0“,”@ angular / forms“:”^ 5.0.0“,”@ angular / http“:”^ 5.0.0“,”@ angular / material“:”^ 5.0.1“,”@ angular / platform-b​​rowser“:”^ 5.0.0“,”@ angular / platform-b​​rowser-dynamic“:”^ 5.0.0“,”@ angular / router“:”^ 5.0.0“,”@ types / three“:”^ 0.84.35“,”animate.css“:”^ 3.5.2“,”bootstrap“:”^ 3.3.7“,”core -js“:”^ 2.4.1“,”d3“:”^ 4.12.0“,”hammerjs“:”^ 2.0.8“,”jquery“:”^ 3.2.1“,”rxjs“:”^ 5.5.2“,”zone.js“:”^ 0.8.14“},”devDependencies“:{”@ angular / cli“:”1.6.1“,”@ angular / compiler-cli“:”^ 5.0。 0“,”@ angular / language-service“:”^ 5.0.0“,”@ types / d3“:”^ 4.12.0“,”@ types / jasmine“:”~2.5.53“,”@ type / jasminewd2“:”~2.0.2“,”@ types / node“:”~6.0.60“,”codelyzer“:”^ 4.0.1“,”jasmine-core“:”~2.6.2“,” jasmine-spec-reporter“:”~4.1.0“,”karma“:”~1.7.0“,”karma-chrome-launcher“:”~2.1.1“,”karma-cli“:”~1.0。 1“,”karma-coverage-istanbul-reporter“:”^ 1.2.1“,”karma-jasmine“:” ~1.1.0“,”karma-jasmine-html-reporter“:”^ 0.2.2“,”量角器“:”~5.1.2“,”ts-node“:”~3.2.0“,”tslint“ :“~5.7.0”,“打字稿”:“~2.4.2”

import { OnInit } from '@angular/core';
import { Component, ViewChild, ElementRef } from '@angular/core';
import * as THREE from 'three';

@Component({
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.css']
})
export class HomeComponent  {


  @ViewChild('rendererContainer') rendererContainer: ElementRef;
  renderer = new THREE.WebGLRenderer();

以下是我得到的错误。

 /Users/macmini05/Desktop/nieu/src/three doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/macmini05/Desktop/nieu/src/three.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/macmini05/Desktop/nieu/src/three.js doesn't exist
            as directory
              /Users/macmini05/Desktop/nieu/src/three doesn't exist
      looking for modules in /Users/macmini05/Desktop/nieu/src
        using description file: /Users/macmini05/Desktop/nieu/package.json (relative path: ./src)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Users/macmini05/Desktop/nieu/package.json (relative path: ./src)
          using description file: /Users/macmini05/Desktop/nieu/package.json (relative path: ./src/three)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/macmini05/Desktop/nieu/src/three doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/macmini05/Desktop/nieu/src/three.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias 
答案

看看你的package.json你缺少three js。你只安装了@types/three,它只是TypeScript的典型代表。

你需要安装three js。

npm install three --save

以上是关于Angular 5,三Js错误的主要内容,如果未能解决你的问题,请参考以下文章

angularJS使用ocLazyLoad实现js延迟加载

获取请求在Angular 5 app中抛出404错误

fs.existsSync 不是 Angular (5) 中的函数

用VSCode开发一个asp.net core 2.0+angular 5项目: Angular5全局错误处理

angular.min.js:118 Error: [ng:areq] http://errors.angularjs.org/1.5.8/ng/areq?

三.ColladaLoader 不是构造函数