首页 > 解决方案 > ng serve 给出错误“发生未处理的异常:无法读取属性 'fileName' of null”

问题描述

我正在尝试以角度构建应用程序,每当我运行时ng serve都会出现错误

发生未处理的异常:无法读取属性 'fileName' of null 有关详细信息,请参阅“C:\Users\user\AppData\Local\Temp\ng-r6zMGl\angular-errors.log”。

这是我的 package.json 文件内容,

{
  "name": "shop-app",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~11.2.10",
    "@angular/common": "~11.2.10",
    "@angular/compiler": "~11.2.10",
    "@angular/core": "~11.2.10",
    "@angular/fire": "^6.1.4",
    "@angular/forms": "~11.2.10",
    "@angular/localize": "~11.2.10",
    "@angular/platform-browser": "~11.2.10",
    "@angular/platform-browser-dynamic": "~11.2.10",
    "@angular/router": "~11.2.10",
    "@ng-bootstrap/ng-bootstrap": "^9.1.1",
    "@popperjs/core": "^2.9.2",
    "bootstrap": "^5.0.1",
    "firebase": "^8.6.1",
    "firebase-tools": "^9.10.2",
    "ng2-validation": "^4.2.0",
    "rxjs": "^6.6.7"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1102.9",
    "@angular/cli": "~11.2.9",
    "@angular/compiler-cli": "~11.2.10",
    "@types/jasmine": "~3.6.0",
    "@types/node": "^12.11.1",
    "codelyzer": "^6.0.0",
    "jasmine-core": "^3.7.1",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~6.1.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~4.1.5"
  }
}

和日志文件内容,

[error] TypeError: Cannot read property 'fileName' of null
    at Object.getImportRewriter (<path>AngularProjects\shop-app\node_modules\@angular\compiler-cli\ngcc\src\rendering\utils.js:23:72)
    at DtsRenderer.renderDtsFile (<path>AngularProjects\shop-app\node_modules\@angular\compiler-cli\ngcc\src\rendering\dts_renderer.js:77:72)
    at <path>AngularProjects\shop-app\node_modules\@angular\compiler-cli\ngcc\src\rendering\dts_renderer.js:69:134
    at Map.forEach (<anonymous>)
    at DtsRenderer.renderProgram (<path>AngularProjects\shop-app\node_modules\@angular\compiler-cli\ngcc\src\rendering\dts_renderer.js:69:26)
    at Transformer.transform (<path>AngularProjects\shop-app\node_modules\@angular\compiler-cli\ngcc\src\packages\transformer.js:93:52)
    at <path>AngularProjects\shop-app\node_modules\@angular\compiler-cli\ngcc\src\execution\create_compile_function.js:52:42
    at SingleProcessExecutorSync.SingleProcessorExecutorBase.doExecute (<path>AngularProjects\shop-app\node_modules\@angular\compiler-cli\ngcc\src\execution\single_process_executor.js:36:17)
    at <path>AngularProjects\shop-app\node_modules\@angular\compiler-cli\ngcc\src\execution\single_process_executor.js:57:59
    at SyncLocker.lock (<path>AngularProjects\shop-app\node_modules\@angular\compiler-cli\ngcc\src\locking\sync_locker.js:34:24)
    at SingleProcessExecutorSync.execute (<path>AngularProjects\shop-app\node_modules\@angular\compiler-cli\ngcc\src\execution\single_process_executor.js:57:27)
    at Object.mainNgcc (<path>AngularProjects\shop-app\node_modules\@angular\compiler-cli\ngcc\src\main.js:74:25)
    at Object.process (<path>AngularProjects\shop-app\node_modules\@angular\compiler-cli\ngcc\index.js:29:23)
    at NgccProcessor.processModule (<path>AngularProjects\shop-app\node_modules\@ngtools\webpack\src\ngcc_processor.js:163:16)
    at <path>AngularProjects\shop-app\node_modules\@ngtools\webpack\src\ivy\host.js:109:18
    at <path>AngularProjects\shop-app\node_modules\@ngtools\webpack\src\ivy\host.js:39:24


在将 Angular 7 更新到 Angular 9 后无法读取属性 'fileName' 中看到此链接错误,但它没有明确的答案。如果有人可以帮助我,我真的很感激。

编辑:安装 angular-4-data-table 库后出现此错误。如果我删除它没有错误,但我需要这个库。

标签: angulartypescript

解决方案


推荐阅读