Nativescript角度编译错误没有|new|无法调用类构造函数



Nativescript angular项目成功构建,但在tns运行ios或tns运行android时抛出错误。无法编译并将angular升级到10。我已经更新到最新的zone.js,并添加了ngcc.congif.js文件。我已经使用tns升级更新了nativescripty,删除了平台并添加了平台。它为ios和android抛出了不同的错误。

包.json

{
"name": "sample-angular",
"version": "0.0.0",
"scripts": {
"android": "tns run android",
"ios": "tns run ios",
"mobile": "tns run",
"preview": "tns preview",
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"post-build": "node ./build/post-build.js",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"ngcc": "ngcc --properties es2015 module main --first-only",
"postinstall": "npm run ngcc"
},
"private": true,
"dependencies": {
"@angular/animations": "^10.0.0",
"@angular/cdk": "^10.0.0",
"@angular/common": "^10.0.0",
"@angular/compiler": "^10.0.0",
"@angular/compiler-cli": "^10.0.0",
"@angular/core": "^10.0.0",
"@angular/fire": "^5.2.1",
"@angular/flex-layout": "^9.0.0-beta.31",
"@angular/forms": "^10.0.0",
"@angular/localize": "^10.0.0",
"@angular/material": "^10.0.0",
"@angular/platform-browser": "^10.0.0",
"@angular/platform-browser-dynamic": "^10.0.0",
"@angular/router": "^10.0.0",
"@danielmoncada/angular-datetime-picker": "^9.4.2",
"@nativescript/angular": "^9.0.0",
"@nativescript/core": "~6.5.0",
"@nativescript/schematics": "^1.0.0",
"@nativescript/theme": "~2.2.1",
"@ngdesk/data-api": "file:ngdesk-swagger/data-api/dist/ngdesk-data-api-1.0.0.tgz",
"@ngdesk/escalation-api": "file:ngdesk-swagger/escalation-api/dist/ngdesk-escalation-api-1.0.0.tgz",
"@ngdesk/payment-api": "file:ngdesk-swagger/payment-api/dist/ngdesk-payment-api-1.0.0.tgz",
"@ngdesk/sam-api": "file:ngdesk-swagger/sam-api/dist/ngdesk-sam-api-1.0.0.tgz",
"@ngdesk/sidebar-api": "file:ngdesk-swagger/sidebar-api/dist/ngdesk-sidebar-api-1.0.0.tgz",
"@ngx-translate/core": "^11.0.1",
"@ngx-translate/http-loader": "^4.0.0",
"@nstudio/nativescript-checkbox": "^1.0.0",
"@stomp/ng2-stompjs": "^7.2.0",
"@swimlane/ngx-charts": "^12.1.0",
"@types/googlemaps": "^3.38.1",
"acorn": "^6.1.1",
"angular-gridster2": "^8.2.0",
"angular2-uuid": "^1.1.1",
"chart.js": "^2.9.3",
"core-js": "^2.6.8",
"fast-text-encoding": "^1.0.0",
"firebase": "^7.0.0",
"font-awesome": "^4.7.0",
"i": "^0.3.6",
"jwt-decode": "^2.2.0",
"linkifyjs": "^2.1.8",
"material-design-icons": "^3.0.1",
"material-icons": "^0.3.1",
"moment": "^2.24.0",
"moment-timezone": "^0.5.25",
"nativescript-angular": "^8.21.0",
"nativescript-easy-notification-banner": "^1.1.0",
"nativescript-feedback": "^1.3.12",
"nativescript-fontawesome": "^1.0.0",
"nativescript-ng2-fonticon": "^1.3.4",
"nativescript-ngx-fonticon": "^6.0.3",
"nativescript-plugin-firebase": "^10.5.2",
"nativescript-ui-listview": "^8.2.0",
"nativescript-websockets": "^1.5.5",
"ng2-charts": "^2.3.0",
"ng2-translate": "^5.0.0",
"ngx-build-plus": "^8.0.3",
"ngx-cookie-service": "^3.0.3",
"ngx-logger": "^3.3.13",
"ngx-mat-select-search": "^2.1.1",
"ngx-select-ex": "^3.7.7",
"ngx-tinymce": "^7.0.0",
"npm": "^6.12.1",
"p-try": "^2.2.0",
"reflect-metadata": "~0.1.12",
"rxjs": "^6.5.5",
"terser-webpack-plugin": "^1.3.0",
"tinymce": "^5.0.8",
"tns-core-modules": "^6.5.8",
"tslib": "^1.10.0",
"webpack": "^4.42.1",
"xlsx": "^0.15.2",
"zone.js": "^0.10.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1000.0",
"@angular/cli": "^10.0.1",
"@angular/compiler-cli": "~8.2.0",
"@angular/language-service": "^10.0.0",
"@nativescript/schematics": "~1.0.0",
"@nativescript/tslint-rules": "~0.0.5",
"@ngtools/webpack": "~9.1.0",
"@types/jasmine": "~3.3.13",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.12.48",
"@types/stripe-v3": "^3.1.19",
"@types/webpack-env": "^1.13.9",
"codelyzer": "^5.1.2",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.5",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"nativescript-dev-webpack": "^1.5.1",
"ng-mocks": "^9.0.0",
"node-sass": "^4.12.0",
"protractor": "~5.4.2",
"rxjs-tslint-rules": "^4.33.3",
"tns-platform-declarations": "^6.5.1",
"ts-node": "~8.2.0",
"tslint": "~6.1.0",
"typescript": "~3.9.5",
"uglifyjs-webpack-plugin": "^2.1.3",
"webpack-bundle-analyzer": "^3.8.0"
},
"nativescript": {
"id": "com.ngdesk.sample",
"tns-ios": {
"version": "6.5.1"
},
"tns-android": {
"version": "6.5.2"
}
}
}

tsconfig.json

{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2020",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2018",
"strict": false,
"skipLibCheck": true,
"typeRoots": ["node_modules/@types"],
"lib": ["es2018", "dom"],
"paths": {
"core-js/es6/reflect": [
"node_modules/core-js/proposals/reflect-metadata"
],
"core-js/es6/*": ["node_modules/core-js/es"],
"core-js/es7/*": ["node_modules/core-js/es"],
"@src/*": [
"src/*.android.ts",
"src/*.ios.ts",
"src/*.tns.ts",
"src/*.web.ts",
"src/*"
]
}
},
"angularCompilerOptions": {
"enableIvy": true
}
}

运行tns run ios时出错--捆绑

Native stack trace:
1   0x10162802e NativeScript::reportFatalErrorBeforeShutdown(JSC::ExecState*, JSC::Exception*, bool)
2   0x101679f94 -[TNSRuntime executeModule:referredBy:]
3   0x100c77023 main
4   0x7fff5227ec25 start
5   0x1
JavaScript stack trace:
PlatformRef(file: node_modules/@angular/core/fesm2015/core.js:27640:0)
at NativeScriptPlatformRef(file: node_modules/@nativescript/angular/platform-common.js:65:0)
at platformNativeScriptDynamic(file: node_modules/@nativescript/angular/platform.js:40:0)
at file:///app/bundle.js:13390:82
at ./main.tns.ts(file:///app/bundle.js:13395:34)
at __webpack_require__(file: src/webpack/bootstrap:816:0)
at checkDeferredModules(file: src/webpack/bootstrap:43:0)
at webpackJsonpCallback(file: src/webpack/bootstrap:30:0)
at anonymous(file:///app/bundle.js:2:61)
at evaluate([native code])
at moduleEvaluation([native code])
at [native code]
at asyncFunctionResume([native code])
at [native code]
at promiseReactionJob([native code])
JavaScript error:
file: node_modules/@angular/core/fesm2015/core.js:27640:0: JS ERROR TypeError: Cannot call a class constructor without |new|
(CoreFoundation) *** Terminating app due to uncaught exception 'NativeScript encountered a fatal error: TypeError: Cannot call a class constructor without |new|
at
PlatformRef(file: node_modules/@angular/core/fesm2015/core.js:27640:0)
at NativeScriptPlatformRef(file: node_modules/@nativescript/angular/platform-common.js:65:0)
at platformNativeScriptDynamic(file: node_modules/@nativescript/angular/platform.js:40:0)
at file:///app/bundle.js:13390:82
at ./main.tns.ts(file:///app/bundle.js:13395:34)
at __webpack_require__(file: src/webpack/bootstrap:816:0)
at checkDeferredModules(file: src/webpack/bootstrap:43:0)
at webpackJsonpCallback(file: src/webpack/bootstrap:30:0)
at anonymous(file:///app/bundle.js:2:61)
at evaluate([native code])
at moduleEvaluation([native code])
at [native code]
at asyncFunctionResume([native code])
at [native code]
at promiseReactionJob([native code])
', reason: '(null)'
*** First throw call stack:
(
0   CoreFoundation                      0x00007fff23c7127e __exceptionPreprocess + 350
1   libobjc.A.dylib                     0x00007fff513fbb20 objc_exception_throw + 48
2   NativeScrip<…>
NativeScript caught signal 6.
Native Stack:
1   0x101678be1 sig_handler(int)
2   0x7fff5245a5fd _sigtramp
3   0x1
4   0x7fff5234ba5c abort
5   0x7fff502497f8 __cxa_bad_cast
6   0x7fff502499c7 demangling_unexpected_handler()
7   0x7fff513fbd7c _objc_terminate()
8   0x7fff50256e97 std::__terminate(void (*)())
9   0x7fff502568fe __cxa_get_exception_ptr
10  0x7fff502568c5 __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*)
11  0x7fff513fbc44 _objc_exception_destructor(void*)
12  0x10162856f NativeScript::reportFatalErrorBeforeShutdown(JSC::ExecState*, JSC::Exception*, bool)
13  0x101679f94 -[TNSRuntime executeModule:referredBy:]
14  0x100c77023 main
15  0x7fff5227ec25 start
16  0x1

tns运行android时出错--捆绑

Error executing Metadata Generator: java.nio.IntBuffer.clear()Ljava/nio/IntBuffer;
Command ./gradlew failed with exit code 1

不幸的是,我没有答案。我一直坚持使用Angular 9,直到nativescriptt团队还没有正式发布支持Angular 10的nativescript升级版。

我可以对你说的是:试着禁用Ivy编译器,看看它是否至少以这种方式构建和运行应用程序。

最新更新