[英]Angular Universal “Module file (/src/app/.ts) not found”
[英]Angular 7 File '../src/types/@angular/common.d.ts' is not a module
我已经创建了一个新的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'是不是一个模块。 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'是不是一个模块。 src / app / app.routing.ts(1,30):错误TS2306:文件'C:/Users/Marina/Desktop/heliosFrontEnd_admin/src/types/@angular/common.d.ts'不是模块。
根据您的错误日志,您正在使用MatBottomSheet。 因此,您需要从@ angular / material导入MatBottomSheetModule。 还将其包含在导入数组中。
在角形材料中,每个组件都有自己的模块。 因此,在使用该组件之前,请导入其相关模块。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.