angular - Failed sourceRequest
问题描述
i tryed to compile some html code. everything works fine, but when i try to use something like *ngFor
i get an error.
I only noticed it because i used visual studio code an used the firefox debugger.
i work with latest angular version on visual studio code.
@angular-devkit/build-optimizer 0.803.0
@angular-devkit/build-webpack 0.803.0
@angular-devkit/core 8.3.0
@angular-devkit/schematics 8.3.0
@angular/cli 8.3.0
@ngtools/webpack 8.3.0
@schematics/angular 8.3.0
@schematics/update 0.803.0
rxjs 6.4.0
typescript 3.5.3
webpack 4.39.2
i already read something maybe works, but i'm a bit afraid to try it because that are solutions not exactly for my problem i found something here Cannot find module '@angular/compiler' and here Cannot find module '@angular/compiler-cli' when running ng serve
and this is what i used in the html code what thorws the error
<li *ngFor="let karts of karten">
{{karts.art}}
</li>
this is a part of my typescript file
import { Component, OnInit } from '@angular/core';
import { karten } from './karten';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
@NgModule({
declarations: [],
imports: [ CommonModule ],
exports: [],
providers: [],
})
export class BlackjackComponent implements OnInit {
karten=[
{art:'Herz',typ:'Ass'},
{art:'Herz',typ:'König'},
{art:'Herz',typ:'Dame'},
{art:'Herz',typ:'Bube'},
{art:'Herz',typ:'Zehn'}
];
}
the problem while compiling is, that he absolute don't compile anything with this error and i only get an white page in web an the error at vs
this i the error i get
Could not load source 'node_modules\@angular\compiler\fesm2015\compiler.js': Failed sourceRequest: the requested source can't be found.
解决方案
Try This following steps,
1 : npm install -g @angular/cli
2 : ng new "your project name"
3 : ng serve : erro >>> do not wrray
4 : npm install @angular/compiler-cli
5 : npm install typescript
6 : npm install @angular/cli