无法读取未定义的属性(读取“kind”)

问题描述 投票:0回答:4

这些天我正在开发一个 Angular-CLI 项目。昨天,当我尝试在那里创建一个新模块时,终端给出了一个错误,说

Cannot read properties of undefined (reading 'kind')

(只有这个错误没有任何其他解释)

然后我发现以同样的方式角度不允许制作新组件并给出相同的错误。但是

ng serve
命令没有任何问题。可以正常使用。

如果你能帮我解决这个问题,那将是一个很大的帮助。我将包含一些文件。但如果您想要更多详细信息,请在评论中提及它们,因为我不明白问题出在哪里。预先感谢

package.json

{
  "name": "chess-cabin-front",
  "version": "0.0.0",
  "scripts": {
    "android": "ns run android --no-hmr",
    "ios": "ns run ios --no-hmr",
    "mobile": "ns run",
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~11.0.4",
    "@angular/cdk": "^11.2.5",
    "@angular/common": "~11.0.4",
    "@angular/compiler": "~11.0.4",
    "@angular/core": "~11.0.4",
    "@angular/forms": "~11.0.4",
    "@angular/localize": "~11.0.4",
    "@angular/material": "^11.2.5",
    "@angular/platform-browser": "~11.0.4",
    "@angular/platform-browser-dynamic": "~11.0.4",
    "@angular/router": "~11.0.4",
    "@ctrl/ngx-emoji-mart": "^6.0.0",
    "@nativescript/angular": "~10.1.0",
    "@nativescript/core": "~7.0.0",
    "@nativescript/theme": "~2.5.0",
    "@ng-bootstrap/ng-bootstrap": "^9.1.3",
    "@types/jquery": "^3.5.5",
    "admin-lte": "^3.1.0-rc",
    "angular-in-memory-web-api": "^0.11.0",
    "angularx-social-login": "^3.5.7",
    "bootstrap": "^4.6.0",
    "emojionearea": "^3.4.2",
    "font-awesome": "^4.7.0",
    "ionicons": "^5.2.3",
    "jquery": "^3.5.1",
    "reflect-metadata": "~0.1.12",
    "rxjs": "^6.6.0",
    "tslib": "^2.0.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1100.4",
    "@angular/cli": "~11.0.4",
    "@angular/compiler-cli": "~11.0.4",
    "@nativescript/android": "8.0.0",
    "@nativescript/schematics": "^11.2.0",
    "@nativescript/tslint-rules": "~0.0.5",
    "@nativescript/webpack": "~3.0.0",
    "@types/jasmine": "~3.6.0",
    "@types/node": "^12.11.1",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.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",
    "ngx-progressbar": "^6.1.1",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~4.0.2"
  },
  "main": "main.tns.js"
}

angular.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "Chess-Cabin-Front": {
      "projectType": "application",
      "schematics": {
        "@schematics/angular:component": {
          "style": "scss"
        },
        "@schematics/angular:application": {
          "strict": true
        }
      },
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/Chess-Cabin-Front",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "aot": true,
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.scss",
              "node_modules/@ctrl/ngx-emoji-mart/picker.css",
              "node_modules/bootstrap/dist/css/bootstrap.min.css"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "webpack.config.js"
            ],
            "allowedCommonJsDependencies": [
              "$.widget.bridge('uibutton', $.ui.button)",
              "admin-lte/plugins/bootstrap/js/bootstrap.bundle.min.js",
              "admin-lte/plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js",
              "admin-lte/dist/js/adminlte.js"
            ]
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "namedChunks": false,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "500kb",
                  "maximumError": "1mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "2kb",
                  "maximumError": "4kb"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "Chess-Cabin-Front:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "Chess-Cabin-Front:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "Chess-Cabin-Front:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.spec.json",
            "karmaConfig": "karma.conf.js",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.scss"
            ],
            "scripts": []
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "tsconfig.app.json",
              "tsconfig.spec.json",
              "e2e/tsconfig.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        },
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "Chess-Cabin-Front:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "Chess-Cabin-Front:serve:production"
            }
          }
        }
      }
    }
  },
  "defaultProject": "Chess-Cabin-Front",
  "cli": {
    "defaultCollection": "@nativescript/schematics"
  }
}

angular typescript angular-cli
4个回答
19
投票

我偶然发现了同样的问题(使用 Angular v15.1.0 和 TS v4.8.3),将 typescript 升级到 v4.9.4 为我解决了!


4
投票

我遇到了同样的问题,就我而言,我在自己的组件中使用动画,因此已经包含了 Brower 动画模块。

答案就在这个论坛,我刚刚添加了@angular/material,但不包括动画模块


0
投票

对我来说,以下步骤有效:

  1. 删除文件夹
    node_modules
  2. 删除文件
    package-lock.json
  3. 奔跑
    npm install

0
投票

出现此错误是因为您的工作目录缺少某些依赖项。 要解决这个问题,您应该清理并重建您的依赖关系。 请按照此步骤操作: 步骤 1 删除你的node_modules文件夹

  1. $ rm -rf 节点模块

或在 Windows 上: $ rmdir /s 节点模块

第2步干净现金

  1. npm 缓存清理 --force

第3步安装新的node_module文件夹

  1. npm 安装

欲了解更多信息请查看此处

© www.soinside.com 2019 - 2024. All rights reserved.