一切正常,直到我开始在app.module中添加组件。我有2个文件夹,一个连接到数据库(Mongodb)的后端和一个用于查看项目的前端。当我运行后端时,它会连接,但是当我运行前端时,它会给我这个错误:
"ERROR in ../node_modules/@auth0/angular-jwt/index.d.ts(1,47): error TS2307:
Cannot find module '@angular/core'.
../node_modules/@auth0/angular-jwt/src/jwt.interceptor.d.ts(1,70): error
TS2307: Cannot find module '@angular/common/http'.
../node_modules/@auth0/angular-jwt/src/jwt.interceptor.d.ts(3,28): error
TS2307: Cannot find module 'rxjs/internal/Observable'.
../node_modules/@auth0/angular-jwt/src/jwtoptions.token.d.ts(1,32): error
TS2307: Cannot find module '@angular/core'."
我的代码在下面。
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import { HttpClientModule } from '@angular/common/http';
import { ApiService } from './api.service';
import {MatButtonModule, MatToolbarModule, MatInputModule} from '@angular/material';
import {BrowserAnimationsModule, NoopAnimationsModule} from '@angular/platform-browser/animations';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MatListModule} from '@angular/material/list';
import { RegisterComponent } from './register/register.component';
import { LoginComponent } from './login/login.component';
import { MessageComponent } from './messages/message.component';
import { AboutusComponent } from './aboutus/aboutus.component';
import {AddnewsComponent} from './addnews/addnews.component';
import {NewsListComponent} from './newslist/newslist.component';
import {ViewComponent} from './view/view.component';
@NgModule({
declarations: [
AppComponent, MessageComponent, RegisterComponent, LoginComponent,AboutusComponent,AddnewsComponent,NewsListComponent,ViewComponent
],
imports: [
BrowserModule, HttpClientModule, FormsModule, ReactiveFormsModule, MatButtonModule, MatInputModule, MatToolbarModule, BrowserAnimationsModule,
NoopAnimationsModule, MatListModule, RouterModule.forRoot(
[
{path: 'addnews', component:AddnewsComponent},
{path: 'aboutus', component: AboutusComponent},
{path: 'newslist',component: NewsListComponent},
{path: 'view', component: ViewComponent},
{path: 'register', component: RegisterComponent},
{path: 'login', component: LoginComponent},
{path: 'messages', component: MessageComponent}
]
)
],
providers: [ApiService],
bootstrap: [AppComponent]
} )
export class AppModule { }
答案 0 :(得分:0)
这取决于已将哪些依赖项添加到组件。另外,您是否要导入@ auth0 / angular-jwt所需的angular公共模块? It's peer dependencies要求角度共通-