Nativescript: iOS crash when running with release/production flag: Can't find variable: __metadata

Created on 19 Aug 2020  Â·  15Comments  Â·  Source: NativeScript/NativeScript

Simply copy steps from here: https://nativescript.org/blog/upgrading-tips-for-angular-10/

npm i -g @angular/cli // You could be needing to prefix sudo on GNU/Linux and other Unix-like OSes.
npm i -g nativescript // You could be needing to prefix sudo on GNU/Linux and other Unix-like OSes.
npm i -g @nativescript/schematics // You could be needing to prefix sudo on GNU/Linux and other Unix-like OSes.

ng new workspace
cd workspace
ng add @nativescript/schematics --skipAutoGeneratedComponent

// start apps:
npm run ios --> this runs fine
npm run ios -- --release   --> this will cause error below
npm run ios -- --env.production   --> this will cause error below

Any idea why? Tried to search for solution but can't find any.
Happens to my existing project as well after upgrading to angular 10. Right now I can't seem to deploy the iOS app due to this issue. It's causing the app to crash on launching.

JavaScript stack trace:
file:///app/vendor.js:90935:15
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:84982:90
at file:///app/vendor.js:85830:34
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:42890:97
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:62743:87
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:35266:89
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:64700:87
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:66519:95
at file:///app/vendor.js:71822:34
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/bundle.js:51:47
at __webpack_require__(file:///app/runtime.js:75:34)
at checkDeferredModules(file:///app/runtime.js:44:42)
at webpackJsonpCallback(file:///app/runtime.js:31:39)
at anonymous(file:///app/bundle.js:2:61)
at evaluate([native code])
at moduleEvaluation([native code])
at [native code]
at asyncFunctionResume([nativ<…>
JavaScript error:
file:///app/vendor.js:90935:15: JS ERROR ReferenceError: Can't find variable: __metadata
(CoreFoundation) *** Terminating app due to uncaught exception 'NativeScript encountered a fatal error: ReferenceError: Can't find variable: __metadata
at
file:///app/vendor.js:90935:15
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:84982:90
at file:///app/vendor.js:85830:34
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:42890:97
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:62743:87
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:35266:89
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:64700:87
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/vendor.js:66519:95
at file:///app/vendor.js:71822:34
at __webpack_require__(file:///app/runtime.js:75:34)
at file:///app/bundle.js:51:47
at __webpack_require__(file:///app/runtime.js:75:34)
at checkDeferredModules(file:///app/runtime.js:44:42)
at webpackJsonpCallback(file:///app/runtime.js:31:39)
at anonym<…>
NativeScript caught signal 6.
Native Stack:
1   0x103596171 sig_handler(int)
2   0x7fff522ab5fd _sigtramp
3   0x7fff5219ff39 itoa64
4   0x7fff5219bb7c abort
5   0x7fff500a2858 abort_message
6   0x7fff50093cbf demangling_unexpected_handler()
7   0x7fff51253c0b _objc_terminate()
8   0x7fff500a1c87 std::__terminate(void (*)())
9   0x7fff500a440b __cxa_get_exception_ptr
10  0x7fff500a43d2 __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*)
11  0x7fff51253ad6 _objc_exception_destructor(void*)
12  0x103545b6f NativeScript::reportFatalErrorBeforeShutdown(JSC::ExecState*, JSC::Exception*, bool)
13  0x103597524 -[TNSRuntime executeModule:referredBy:]
14  0x102e8f4bf main
15  0x7fff520ce1fd start
JS Stack:

Most helpful comment

@nativescript/[email protected] and @nativescript/[email protected] seems to be working, thank you!

@farfromrefug Nathan released @nativescript/[email protected] a couple hours ago.

All 15 comments

Hi @nabilzhafri
Thank you for reporting this issue.
We are going to try replicate this case on our end. Let me know if you can send us a sample project that can reproduce the issue.
For now, can you try doing following steps and let me know how it goes:

1) Delete the following files/folders:
node_modules
platforms
hooks
package-lock.json
webpack.config.js

2) Run: npm i

3) Then just rebuild the project: tns run

@Ross-Olivares hi. for sample project, you can just follow instruction above.

Simply copy steps from here: https://nativescript.org/blog/upgrading-tips-for-angular-10/

If you'd like another sample project that exhibits this behavior, ns create and choose the Angular 'hello world' template - it has the same issue.

@grey280 @nabilzhafri I think your issue is fixed in 7.0.5

@farfromrefug Nope - tested again with the Angular 'hello world' template after updating @nativescript/core to 7.0.5, same issue. Here's the stack trace from Xcode, if it's any help:

Terminating app due to uncaught exception 'NativeScript encountered a fatal error: Uncaught ReferenceError: __metadata is not defined
 at 
    (file:///app/vendor.js:91370:5)
    at __webpack_require__(file:///app/runtime.js:75:30)
    at (file:///app/vendor.js:85324:71)
    at (file:///app/vendor.js:86173:30)
    at __webpack_require__(file:///app/runtime.js:75:30)
    at (file:///app/vendor.js:42898:78)
    at __webpack_require__(file:///app/runtime.js:75:30)
    at (file:///app/vendor.js:62042:68)
    at __webpack_require__(file:///app/runtime.js:75:30)
    at (file:///app/vendor.js:35262:70)
    at __webpack_require__(file:///app/runtime.js:75:30)
    at (file:///app/vendor.js:69704:68)
    at __webpack_require__(file:///app/runtime.js:75:30)
    at (file:///app/vendor.js:64190:76)
    at (file:///app/vendor.js:69531:30)
    at __webpack_require__(file:///app/runtime.js:75:30)
    at 326(file:///app/bundle.js:51:28)
    at __webpack_require__(file:///app/runtime.js:75:30)
    at checkDeferredModules(file:///app/runtime.js:44:23)
    at webpackJsonpCallback(file:///app/runtime.js:31:19)
    at (file:///app/bundle.js:2:57)
    at require(:1:137)
', reason: '(null)'

Did you update @nativescript/webpack? It needs an update too

This is with @nativescript/[email protected], which is the latest version I see available on NPM.

I also tested by pulling this repo, building @nativescript/webpack from source, and dropping the result into node_modules, and had the same issue. (Admittedly, I'm not certain that I built @nativescript/webpack correctly, or that moving it into node_modules like that will even work how I was expecting it to.)

@grey280 you are right a new webpack release is missing https://github.com/NativeScript/NativeScript/pull/8884

I saw the new WebPack release go out earlier this morning, and just finished testing the 'hello world' app using that. Didn't resolve the problem.

@NathanWalker we need a new wepback release don't we? Will still fail because of the bundle config loader

@nativescript/[email protected] and @nativescript/[email protected] seems to be working, thank you!

@farfromrefug Nathan released @nativescript/[email protected] a couple hours ago.

Awesome then!

Thanks for confirmation @grey280 please let us know if you encounter anything else.

Was this page helpful?
0 / 5 - 0 ratings