Я создал новый проект Angular 7, и в ap.routing.ts у меня есть
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule, Routes } from '@angular/router';
import { ClientsComponent } from './components/clients/clients.component';
import { HomeComponent } from './components/commons/home/home.component';
import { FunctionalitiesComponent } from './components/functionalities/functionalities.component';
import { ProcessesComponent } from './components/processes/processes.component';
import { ProjectsComponent } from './components/projects/projects.component';
import { UsersComponent } from './components/users/users.component';
import { AuthenticationGuard } from './_guards/authentication.guard';
import { LoginComponent } from './components/users/login/login.component';
import { RegistrationComponent } from './components/users/registration/registration.component';
const routes: Routes = [
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', component: HomeComponent, canActivate: [AuthenticationGuard] },
{ path: 'clients', component: ClientsComponent },
{ path: 'projects', component: ProjectsComponent },
{ path: 'functionalities', component: FunctionalitiesComponent },
{ path: 'processes', component: ProcessesComponent },
{ path: 'login', component: LoginComponent },
{ path: 'users', component: UsersComponent }
];
@NgModule({
imports: [
CommonModule,
BrowserModule,
RouterModule.forRoot(routes, { enableTracing: true , onSameUrlNavigation: 'reload'})
],
exports: [
],
})
export class AppRoutingModule { }
'@ angular / common' подчеркнут красным и выдается следующая ошибка:
File '{pathTo}/src/types/@angular/common.d.ts' is not a module
Я установил модуль с помощью
npm i @angular/common
, перезапустил визуальный редактор (VS Code), перезапустил ng serve
, но ничего не изменилось.
Это файл package.json:
{
"name": "material-dashboard-angular",
"version": "2.2.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve --base-href /admin/",
"build": "ng build --aot --base-href /admin/",
"build-prod": "ng build --prod --aot",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"install:clean": "rm -rf node_modules/ && rm -rf package-lock.json && npm install && ng serve -o"
},
"engines": {
"node": "6.11.1",
"npm": "3.10.9"
},
"private": true,
"dependencies": {
"@agm/core": "1.0.0-beta.5",
"@angular/animations": "7.0.2",
"@angular/cdk": "7.0.2",
"@angular/common": "7.0.2",
"@angular/compiler": "7.0.2",
"@angular/core": "7.0.2",
"@angular/forms": "7.0.2",
"@angular/http": "7.0.2",
"@angular/material": "7.0.2",
"@angular/platform-browser": "7.0.2",
"@angular/platform-browser-dynamic": "7.0.2",
"@angular/platform-server": "7.0.2",
"@angular/router": "7.0.2",
"@auth0/angular-jwt": "^2.1.0",
"@ngx-translate/core": "^11.0.1",
"@ngx-translate/http-loader": "^4.0.0",
"acorn": "^6.1.1",
"ajv": "6.4.0",
"angular-http-server": "^1.9.0",
"angular-svg-icon": "^7.2.1",
"arrive": "2.4.1",
"bootstrap": "4.1.0",
"bootstrap-material-design": "4.1.1",
"bootstrap-notify": "3.1.3",
"chartist": "0.11.0",
"classlist.js": "1.1.20150312",
"core-js": "2.4.1",
"cron-validator": "^1.0.1",
"express": "4.16.3",
"file-input-accessor": "^7.0.0",
"googleapis": "28.1.0",
"hammerjs": "2.0.8",
"jquery": "^3.4.1",
"moment": "2.22.1",
"perfect-scrollbar": "1.1.0",
"popper.js": "1.14.3",
"rxjs": "6.3.3",
"rxjs-compat": "6.3.3",
"sancronos-validator": "^1.2.0",
"web-animations-js": "2.3.1",
"zone.js": "0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.13.9",
"@angular/cli": "6.0.3",
"@angular/compiler-cli": "^7.2.15",
"@angular/language-service": "7.0.2",
"@types/bootstrap": "3.3.32",
"@types/chartist": "0.9.34",
"@types/googlemaps": "3.30.8",
"@types/jasmine": "2.5.38",
"@types/jquery": "1.10.31",
"@types/node": "^6.0.73",
"codelyzer": "4.2.1",
"jasmine-core": "3.1.0",
"jasmine-spec-reporter": "4.2.1",
"karma": "^4.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-cli": "1.0.1",
"karma-coverage-istanbul-reporter": "1.4.2",
"karma-jasmine": "1.1.1",
"protractor": "^6.0.0",
"ts-node": "5.0.1",
"tslint": "5.9.1",
"typescript": "3.1.6"
}
}
ЖУРНАЛ ОШИБКИ
ОШИБКА в node_modules/@angular/cdk/overlay/typings/overlay-ref.d.ts (11,26): ошибка TS2306: Файл 'C: /Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts' не является модулем.node_modules/@angular/cdk/overlay/typings/overlay.d.ts (9,26): ошибка TS2306: файл 'C: /Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.tsэто не модуль.node_modules/@angular/material/bottom-sheet/typings/bottom-sheet-ref.d.ts (8,26): ошибка TS2306: файл 'C: / Users / Marina / Desktop / heliosFrontEnd_admin / src / types / @ angular/common.d.ts 'не является модулем.node_modules/@angular/material/bottom-sheet/typings/bottom-sheet.d.ts (11,26): ошибка TS2306: файл 'C: / Users / Marina / Desktop / heliosFrontEnd_admin / src / types / @ angular / common.d.ts 'не является модулем.node_modules/@angular/material/dialog/typings/dialog-ref.d.ts (9,26): ошибка TS2306: файл 'C: /Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts 'не является модулем.node_modules/@angular/material/dialog/typings/dialog.d.ts (10,26): ошибка TS2306: файл 'C: /Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.tsэто не модуль.node_modules/@angular/platform-browser/src/browser/location/browser_platform_location.d.ts (8,58): ошибка TS2306: файл 'C: / Users / Marina / Desktop / heliosFrontEnd_admin / src / types / @ angular / common.d.ts 'не является модулем.node_modules/@angular/router/src/directives/router_link.d.ts (8,34): ошибка TS2306: Файл 'C: /Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.tsэто не модуль.node_modules/@angular/router/src/router.d.ts (8,26): ошибка TS2306: файл 'C: /Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts' isне модуль.node_modules/@angular/router/src/router_module.d.ts (8,106): ошибка TS2306: Файл 'C: /Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts' не являетсямодуль.node_modules/@angular/router/src/router_scroller.d.ts (8,34): ошибка TS2306: файл 'C: /Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts' isне модуль.src / app / app.routing.ts (1,30): ошибка TS2306: Файл 'C: /Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts' не является модулем.