0

我已将 Angular 应用程序从 12 升级到 13,并添加了 eslint 和 Prettier。

在执行 ng lint 时,我面临以下错误

macbook@macbooks-MacBook-Air LegalRegTech.Web.Host % ng lint

Linting "abp-zero-template"...

<--- Last few GCs --->

[18697:0x7f8814800000]   899728 ms: Mark-sweep (reduce) 2036.5 (2081.8) -> 2035.8 (2082.5) MB, 6232.4 / 0.0 ms  (average mu = 0.155, current mu = 0.048) allocation failure scavenge might not succeed
[18697:0x7f8814800000]   906650 ms: Mark-sweep (reduce) 2036.1 (2082.5) -> 2036.0 (2082.5) MB, 6313.6 / 0.0 ms  (average mu = 0.122, current mu = 0.088) allocation failure GC in old space requested


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x101c5a0e5 node::Abort() [/usr/local/bin/node]
 2: 0x101c5a268 node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 3: 0x101dd0597 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 4: 0x101dd0533 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 5: 0x101f6ee55 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
 6: 0x101f72e7b v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/usr/local/bin/node]
 7: 0x101f6f75c v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
 8: 0x101f6cc0a v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
 9: 0x101f79f60 v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
10: 0x101f79fe1 v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
11: 0x101f46f37 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/usr/local/bin/node]
12: 0x1022f2fbf v8::internal::Runtime_AllocateInOldGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
13: 0x102694d99 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/usr/local/bin/node]
14: 0x106be229f 
zsh: abort      ng lint

这是eslint配置

{
  "root": true,
  "ignorePatterns": [
    "projects/**/*"
  ],
  "overrides": [
    {
      "files": [
        "*.ts"
      ],
      "parserOptions": {
        "project": [
          "src/tsconfig.json",
          "e2e/tsconfig.json"
        ],
        "createDefaultProgram": true
      },
      "extends": [
        "plugin:@angular-eslint/recommended",
        "plugin:@angular-eslint/template/process-inline-templates"
      ],
      "plugins": ["prettier"],
      "rules": {
        "prettier/prettier": ["error"],
        "@angular-eslint/component-selector": [
          "error",
          {
            "prefix": "app",
            "style": "kebab-case",
            "type": "element"
          }
        ],
        "@angular-eslint/directive-selector": [
          "error",
          {
            "prefix": "app",
            "style": "camelCase",
            "type": "attribute"
          }
        ]
      }
    },
    {
      "files": [
        "*.html"
      ],
      "extends": [
        "plugin:@angular-eslint/template/recommended"
      ],
      "rules": {}
    }
  ]
}

package.json 中的脚本

"scripts": {
    "ng": "ng",
    "publish": "ng build --prod",
    "start": "ng serve --host 0.0.0.0 --port 4200",
    "hmr": "ng serve --host 0.0.0.0 --port 4200 --hmr",
    "test": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng test",
    "pree2e": "webdriver-manager update --standalone false --gecko false",
    "e2e": "protractor",
    "verbose": "ng serve --host 0.0.0.0 --port 4200 --verbose",
    "bundle-report": "webpack-bundle-analyzer dist/stats.json",
    "analyze": "ng build --prod --stats-json && webpack-bundle-analyzer dist/stats.json",
    "memstart": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng serve --host 0.0.0.0 --port 4200",
    "start-dev": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng serve --host 0.0.0.0 --port 4200 --configuration=development --open",
    "lint": "ng lint"
  },
4

2 回答 2

0

您遇到了ng serve. 尝试增加限制:

包.json

"serve": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng serve"
于 2021-11-24T10:12:13.033 回答
-1

添加"colors": "1.4.0"到 angular package.json 中的分辨率

例如 “分辨率”:{“fstream/**/mkdirp”:“~0.5.1”,“颜色”:“1.4.0”}

于 2022-01-10T08:07:02.000 回答