我有一个代码共享Angular 8 NativeScript 6项目。
当我执行TNS构建时,它会在以下跟踪中失败。杰出的行是致命的错误:无效的标记 - 紧凑型在堆限制分配失败 - javaScript堆中脱离记忆。
tns build android
Preparing project...
Hash: 29a5dd937bd8e4ccc851
Version: webpack 4.30.0
Time: 33853ms
Built at: 07/31/2019 4:34:20 PM
Asset Size Chunks Chunk Names
0.js 29.9 KiB 0 [emitted]
1.js 24 KiB 1 [emitted]
2.js 33.5 KiB 2 [emitted]
bundle.js 235 KiB bundle [emitted] bundle
package.json 133 bytes [emitted]
runtime.js 15.5 KiB runtime [emitted] runtime
tns-java-classes.js 0 bytes [emitted]
vendor.js 37.1 MiB vendor [emitted] vendor
Entrypoint bundle = runtime.js vendor.js bundle.js
[../$$_lazy_route_resource lazy recursive] ../$$_lazy_route_resource lazy namespace object 160 bytes {bundle} [built]
[./app.css] 450 bytes {bundle} [built]
[./app/app-routing.module.ts] 481 bytes {bundle} [built]
[./app/app.component.css] 275 bytes {bundle} [built]
[./app/app.component.html] 66 bytes {bundle} [built]
[./app/app.component.ts] 749 bytes {bundle} [built]
[./app/app.module.ts] 850 bytes {bundle} [built]
[./app/auth/auth.service.ts] 37 bytes {bundle} [built]
[./app/auth/firebase/firebase-auth.service.ts] 3.38 KiB {bundle} [built]
[./app/auth/helper/nav/nav-helper.service.ts] 776 bytes {bundle} [built]
[./app/auth/login/login.component.ts] 4.3 KiB {bundle} [built]
[./app/core/core.module.ts] 2.95 KiB {bundle} [built]
[./app/home/home.component.ts] 690 bytes {bundle} [built]
[./app/user-profile/user-profile.component.ts] 5.27 KiB {bundle} [built]
[./main.ts] 1.95 KiB {bundle} [built]
+ 837 hidden modules
Webpack compilation complete.
nativescript-plugin-firebase: building for same environment, not forcing prepare.
Project successfully prepared (android)
Configure firebase
Copy C:UsersRobertspynalspynal-appApp_ResourcesAndroidgoogle-services.json to C:UsersRobertspynalspynal-appplatformsandroidappgoogle-services.json.
Building project...
Gradle build...
+ setting applicationId
+ applying user-defined configuration from C:UsersRobertspynalspynal-appApp_ResourcesAndroidapp.gradle
Applying settings from C:UsersRobertspynalspynal-appApp_ResourcesAndroidsettings.json
+ using andorid X library androidx.legacy:legacy-support-v4:1.0.0
+ adding nativescript runtime package dependency: nativescript-optimized-with-inspector
+ adding aar plugin dependency: C:UsersRobertspynalspynal-appnode_modulesnativescript-plugin-firebaseplatformsandroidnativescript_plugin_firebase.aar
+ adding aar plugin dependency: C:UsersRobertspynalspynal-appnode_modulesnativescript-unit-test-runnerplatformsandroidnativescript_unit_test_runner.aar
+ adding aar plugin dependency: C:UsersRobertspynalspynal-appnode_modulestns-core-modules-widgetsplatformsandroidwidgets-release.aar
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 00007FF6479BC6AA v8::internal::GCIdleTimeHandler::GCIdleTimeHandler+4506
2: 00007FF647997416 node::MakeCallback+4534
3: 00007FF647997D90 node_module_register+2032
4: 00007FF647CB189E v8::internal::FatalProcessOutOfMemory+846
5: 00007FF647CB17CF v8::internal::FatalProcessOutOfMemory+639
6: 00007FF647E97F94 v8::internal::Heap::MaxHeapGrowingFactor+9620
7: 00007FF647E8EF76 v8::internal::ScavengeJob::operator=+24550
8: 00007FF647E8D5CC v8::internal::ScavengeJob::operator=+17980
9: 00007FF647E96317 v8::internal::Heap::MaxHeapGrowingFactor+2327
10: 00007FF647E96396 v8::internal::Heap::MaxHeapGrowingFactor+2454
11: 00007FF647FC0637 v8::internal::Factory::NewFillerObject+55
12: 00007FF64803D826 v8::internal::operator<<+73494
13: 000002F1F42DC5C1
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:runSbg'.
> Process 'command 'C:Program FilesAdoptOpenJDKjdk8u192-b12binjava.exe'' finished with non-zero exit value 134
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 47s
Command gradlew.bat failed with exit code 1
WebPack过程似乎可以成功完成,但是Gradle Build conks of Farge Farge。
研究我找到了 - 最大的旧空间大小的节点选项。我只是不知道如何将其应用于Gradle构建过程,或者这是实际问题。任何指导都将不胜感激。
package.json
{
"name": "spynal",
"nativescript": {
"id": "org.nativescript.spynal",
"tns-android": {
"version": "6.0.0"
}
},
"version": "0.0.0",
"scripts": {
"build-prod-ngsw": ""ng build --prod && npm run ngsw-config && npm run ngsw-copy"",
"compile": ""for lang in en; do ng build --output-path=dist/$lang --prod --base-href=/$lang/ --i18n-file=src/locale/messages.$lang.xlf --i18n-format=xlf --i18n-locale=$lang; done"",
"coverage": ""ng test --watch=false --code-coverage"",
"docs": ""compodoc -p tsconfig.json"",
"i18n": ""ng xi18n"",
"ng": "ng",
"ngsw-config": ""ngsw-config dist ngsw-config.json"",
"ngsw-copy": ""cp ./node_modules/@angular/service-worker/ngsw-worker.js dist/"",
"serve-docs": ""compodoc -s -r 4300"",
"serve-prod-ngsw": ""npm run build-prod-ngsw && http-server dist -p 8000"",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"android": "tns run android --bundle",
"ios": "tns run ios --bundle",
"mobile": "tns run --bundle",
"preview": "tns preview --bundle",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
},
"private": true,
"dependencies": {
"@angular/animations": "8.0.2",
"@angular/cdk": "^8.0.1",
"@angular/common": "8.0.2",
"@angular/compiler": "8.0.2",
"@angular/core": "8.0.2",
"@angular/fire": "^5.2.1",
"@angular/flex-layout": "^8.0.0-beta.26",
"@angular/forms": "8.0.2",
"@angular/material": "~8.0.1",
"@angular/platform-browser": "8.0.2",
"@angular/platform-browser-dynamic": "8.0.2",
"@angular/router": "8.0.2",
"@angular/service-worker": "^8.0.2",
"@angular/http": "8.0.0-beta.10",
"bitmovin-player": "^8.10.0",
"core-js": "^3.1.3",
"dashjs": "^2.9.3",
"firebase": "^6.2.0",
"firebase-tools": "^7.0.0",
"fuzzy": "^0.1.3",
"generate-json": "^0.2.2",
"hammerjs": "^2.0.8",
"inquirer-autocomplete-prompt": "^1.0.1",
"nativescript-angular": "^8.0.1",
"nativescript-plugin-firebase": "9.0.2",
"nativescript-theme-core": "~1.0.4",
"nativescript-unit-test-runner": "^0.7.0",
"ng-momentum": "^0.0.24",
"ngx-dropzone": "^1.2.0",
"reflect-metadata": "~0.1.12",
"rx-player": "^3.13.0",
"rxjs": "^6.5.2",
"tns-core-modules": "~6.0.0",
"tslib": "^1.9.0",
"typescript-collections": "^1.3.2",
"videogular2": "^6.4.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.800.0",
"@angular/cli": "^8.0.3",
"@angular/compiler-cli": "8.0.2",
"@nativescript/schematics": "~0.6.0",
"@storybook/addon-actions": "^5.1.9",
"@storybook/addon-links": "^5.1.9",
"@storybook/addon-notes": "^5.1.9",
"@storybook/addons": "^5.1.9",
"@storybook/angular": "^5.1.9",
"@storybook/cli": "^5.1.9",
"@types/core-js": "^2.5.1",
"@types/jasmine": "3.3.13",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~12.0.8",
"axios": "^0.19.0",
"codelyzer": "^5.0.1",
"jasmine-core": "~3.4.0",
"jasmine-marbles": "^0.6.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "4.2.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"karma-nativescript-launcher": "0.4.0",
"karma-webpack": "4.0.2",
"nativescript-dev-webpack": "~1.0.0",
"ng-mocks": "^8.1.0",
"ngx-schematics-for-storybook": "^0.2.2",
"node-fetch": "^2.6.0",
"rxjs-spy": "^7.5.1",
"ts-node": "~8.3.0",
"tslint": "~5.17.0",
"typescript": "3.4.5",
"wait-for-expect": "^1.2.0"
}
}
tsconfig.tns.json
{
"extends": "./tsconfig",
"compilerOptions": {
"module": "esnext",
"moduleResolution": "node"
}
}
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"downlevelIteration": true,
"importHelpers": true,
"outDir": "./dist/out-tsc",
"declaration": false,
"module": "esnext",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom",
"es6",
"es2015.iterable"
],
"baseUrl": ".",
"paths": {
"~/*": [
"src/*"
]
}
},
"exclude": [
"**/*.tns.ts",
"**/*.android.ts",
"**/*.ios.ts",
"**/*.spec.ts",
"**/*.stories.ts"
]
}
尝试此命令以删除node_modules中的致命错误。
node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng build --baseHref=/baseUrl/ --prod=true