UglifyJSPlugin构建时出现内存不足错误

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

我有一个我需要构建的角度6应用程序当我运行时出现以下错误。有办法增加记忆吗?

ng build --configuration=dev


Your global Angular CLI version (7.1.4) is greater than your local
version (6.2.5). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
 92% chunk asset optimization UglifyJSPlugin
<--- Last few GCs --->

[2404:000001F20242CAA0]   153171 ms: Mark-sweep 1340.0 (1440.2) -> 1335.3 (1456.2) MB, 2314.0 / 0.0 ms  (average mu = 0.090, current mu = 0.006) allocation failure scavenge might not succeed
[2404:000001F20242CAA0]   155181 ms: Mark-sweep 1335.4 (1456.2) -> 1335.3 (1456.2) MB, 2007.9 / 0.0 ms  (average mu = 0.047, current mu = 0.001) allocation failure GC in old space requested


<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0000036CD545C5C1]
    1: StubFrame [pc: 0000036CD7BB82E2]
Security context: 0x01275d09e6e1 <JSObject>
    2: add_parameter [00000281CDD2DF79] [0x032bb19026f1 <undefined>:2932] [bytecode=000003B0795083A1 offset=69](this=0x0281cdd2df31 <Object map = 00000253AF59D799>,token=0x0281cdd2e139 <AST_Token map = 00000253AF59DED1>)
    3: binding_element(aka binding_element) [000002B7B84FEBB1] [0x032bb19026f1 <undefined>:~3039]...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 00007FF7E55C121A v8::internal::GCIdleTimeHandler::GCIdleTimeHandler+4810
 2: 00007FF7E559A5B6 node::MakeCallback+4518
 3: 00007FF7E559AFA0 node_module_register+2160
 4: 00007FF7E582B3EE v8::internal::FatalProcessOutOfMemory+846
 5: 00007FF7E582B31F v8::internal::FatalProcessOutOfMemory+639
 6: 00007FF7E5D69304 v8::internal::Heap::MaxHeapGrowingFactor+11476
 7: 00007FF7E5D5FA67 v8::internal::ScavengeJob::operator=+25543
 8: 00007FF7E5D5DFDC v8::internal::ScavengeJob::operator=+18748
 9: 00007FF7E5D66F57 v8::internal::Heap::MaxHeapGrowingFactor+2343
10: 00007FF7E5D66FD6 v8::internal::Heap::MaxHeapGrowingFactor+2470
11: 00007FF7E5909C08 v8::internal::Factory::AllocateRawArray+56
12: 00007FF7E590FF0A v8::internal::Factory::NewTransitionArray+58
13: 00007FF7E5E0F754 v8::internal::CodeStubAssembler::InitializeFunctionContext+27076
14: 00007FF7E5B33AAE v8::internal::JSReceiver::GetOwnPropertyDescriptor+17822
15: 00007FF7E5B33C06 v8::internal::JSReceiver::GetOwnPropertyDescriptor+18166
16: 00007FF7E5B35DBB v8::internal::JSReceiver::GetOwnPropertyDescriptor+26795
17: 00007FF7E5B24B64 v8::internal::JSReceiver::class_name+4228
18: 00007FF7E5B351A9 v8::internal::JSReceiver::GetOwnPropertyDescriptor+23705
19: 00007FF7E59FC7CE v8::internal::LookupIterator::PrepareTransitionToDataProperty+478
20: 00007FF7E5B28CD1 v8::internal::JSReceiver::class_name+20977
21: 00007FF7E58F9FD1 v8::internal::wasm::WasmCodeManager::LookupCode+18929
22: 00007FF7E58FD068 v8::internal::wasm::WasmCodeManager::LookupCode+31368
23: 0000036CD545C5C1

的package.json

{
  "name": "My.Web.Portal",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --configuration=dev",
    "build": "ng build --configuration=dev",
    "build:ssr": "npm run build -- --app=ssr --output-hashing=media",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "bundle-report": "webpack-bundle-analyzer dist/stats.json"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "6.1.10",
    "@angular/cdk": "^6.4.7",
    "@angular/common": "6.1.10",
    "@angular/compiler": "6.1.10",
    "@angular/core": "6.1.10",
    "@angular/forms": "6.1.10",
    "@angular/http": "6.1.10",
    "@angular/material": "^6.4.7",
    "@angular/platform-browser": "6.1.10",
    "@angular/platform-browser-dynamic": "6.1.10",
    "@angular/platform-server": "6.1.10",
    "@angular/router": "6.1.10",
    "@ngrx/effects": "^5.2.0",
    "@ngrx/store": "^5.2.0",
    "@ngrx/store-devtools": "^5.2.0",
    "@nguniversal/module-map-ngfactory-loader": "^5.0.0",
    "angular-bootstrap-datetimepicker": "^2.2.1",
    "angular-font-awesome": "^3.1.2",
    "angular-moment": "^1.3.0",
    "applicationinsights-js": "^1.0.20",
    "aspnet-prerendering": "^3.0.1",
    "bootstrap": "^4.1.3",
    "core-js": "^2.4.1",
    "devextreme": "^18.2.3",
    "devextreme-angular": "^18.2.3",
    "font-awesome": "^4.7.0",
    "fullcalendar-scheduler": "^1.9.4",
    "guid-typescript": "^1.0.9",
    "http-status-codes": "^1.3.0",
    "igniteui-angular": "5.3.1",
    "jquery": "^3.3.1",
    "jszip": "^3.1.5",
    "lodash": "^4.17.11",
    "microsoft-adal-angular6": "^1.0.0",
    "moment": "^2.22.2",
    "mydatepicker": "^2.6.6",
    "ng-fullcalendar": "^1.6.2",
    "ng2-scroll-to-el": "^1.2.1",
    "ngx-joyride": "^2.2.1",
    "ngx-spinner": "^2.0.1",
    "ngx-toastr": "^9.1.1",
    "open-iconic": "^1.1.1",
    "popper.js": "^1.14.4",
    "rxjs": "^6.3.3",
    "rxjs-compat": "^6.3.3",
    "videogular2": "^6.3.0",
    "web-animations-js": "^2.3.1",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.8.6",
    "@angular/cli": "6.2.5",
    "@angular/compiler-cli": "6.1.10",
    "@angular/language-service": "6.1.10",
    "@types/applicationinsights-js": "^1.0.2",
    "@types/jasmine": "^2.8.9",
    "@types/jasminewd2": "^2.0.5",
    "@types/jquery": "^3.3.22",
    "@types/lodash": "^4.14.118",
    "@types/node": "^6.14.0",
    "awesome-typescript-loader": "^5.2.1",
    "codelyzer": "^4.5.0",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^3.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.4.3",
    "karma-jasmine": "^1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^5.4.1",
    "source-map-explorer": "^1.6.0",
    "source-map-loader": "^0.2.4",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "^2.9.2",
    "webpack": "^4.23.1",
    "webpack-bundle-analyzer": "^3.0.3"
  },
  "optionalDependencies": {
    "node-sass": "^4.9.0"
  }
}

angular.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "My.Web.Portal": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist",
            "index": "src/index.html",
            "main": "src/main.ts",
            "tsConfig": "src/tsconfig.app.json",
            "progress": true,
            "polyfills": "src/polyfills.ts",
            "assets": [
              "src/assets"
            ],
            "styles": [
              "node_modules/font-awesome/css/font-awesome.css",
              "node_modules/videogular2/fonts/videogular.css",
              "node_modules/devextreme/dist/css/dx.common.css",
              "node_modules/devextreme/dist/css/dx.light.css",
              "node_modules/ngx-toastr/toastr.css",
              "src/styles.css"
            ],
            "scripts": [
              "node_modules/hammerjs/hammer.min.js",
              "node_modules/popper.js/dist/umd/popper.js",
              "src/app.js"
            ]
          },
          "configurations": {
            "production": {
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ]
            },
            "deploy": {
              "fileReplacements": [
                {
                  "src": "src/environments/environment.ts",
                  "replaceWith": "src/environments/environment.deploy.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "extractLicenses": true,
              "vendorChunk": false

            },
            "dev": {
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "extractLicenses": true,
              "vendorChunk": false,
              "aot": true,
              "buildOptimizer": true,
              "fileReplacements": [
                {
                  "src": "src/environments/environment.ts",
                  "replaceWith": "src/environments/environment.dev.ts"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "My.Web.Portal:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "My.Web.Portal:build:production"
            },
            "deploy": {
              "browserTarget": "My.Web.Portal:build:deploy"
            },
            "dev": {
              "browserTarget": "My.Web.Portal:build:dev"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "My.Web.Portal:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "karmaConfig": "./karma.conf.js",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "scripts": [
              "node_modules/hammerjs/hammer.min.js",
              "src/app.js"
            ],
            "styles": [
              "node_modules/font-awesome/css/font-awesome.css",
              "src/styles.css"
            ],
            "assets": [
              "src/assets"
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "My.Web.Portal-e2e": {
      "root": "e2e",
      "sourceRoot": "e2e",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "./protractor.conf.js",
            "devServerTarget": "My.Web.Portal:serve"
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "e2e/tsconfig.e2e.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "My.Web.Portal",
  "schematics": {
    "@schematics/angular:component": {
      "prefix": "app",
      "styleext": "css"
    },
    "@schematics/angular:directive": {
      "prefix": "app"
    }
  }
}
angular webpack angular-cli
2个回答
2
投票

你能否从项目目录中尝试以下命令。

node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build

0
投票

node --max_old_space_size = 8192 ./node_modules/@angular/cli/bin/ng build增加main.js内存

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