在找不到"AppModule"Angular 6.1.0 的 NgModule 元数据中出错



app.module.ts这是 AppModule 的代码

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { AppComponent } from './app.component';
import { PostListComponent } from './post/post-list.component';
import {PostService} from './post/post.service';
import { HomepageComponent } from './homepage/homepage.component';
import { AppRoutingModule } from './app-routing.module';
@NgModule({
declarations: [
AppComponent,
PostListComponent,
HomepageComponent
],
imports: [
BrowserModule,
HttpClientModule
],
providers: [
PostService
]
bootstrap: [AppComponent]
});
export class AppModule { }

app-routing.module.ts

import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {ProjectListComponent} from '.post/post-list.component';
import {HomePagecomponent} from './homepage/homepage.component';
const routes: Routes =  [
{ path: '', redirectTo: '/home', paathMatch: 'full' },
{ path: 'home', component: HomePagecomponent },
{ path: 'posts', component: PostListComponent},
//{ path: 'post/new', component: PostNewComponent},
//{ path: 'post/show', component: PostShowComponent},
]
@NgModule({
imports: [ RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule{
}

根据需要注释其他代码以帮助我,您也可以共享教程和其他与主题相关的数据。谢谢 主文件目录

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.log(err));

在这里分享了我的主.ts文件。

试试这个:

1(擦除node_modules文件夹,然后:

npm cache clean --force
npm install
npm install --save-dev @angular/cli@latest

最新更新