NativeScript / nativescript-app-sync

♻️ Update your app without going through the app store!
MIT License
125 stars 24 forks source link

Plugin causes Angular apps to crash #42

Closed tjvantoll closed 4 years ago

tjvantoll commented 4 years ago

Hey @EddyVerbruggen,

Went to add this plugin to a new app today and noticed that it causes the app to crash at runtime with a somewhat cryptic error.

JavaScript error:
file:///node_modules/properties/lib/stringify.js:9:17: JS ERROR TypeError: undefined is not an object (evaluating 'global.process.platform')
(CoreFoundation) *** Terminating app due to uncaught exception 'NativeScript encountered a fatal error: TypeError: undefined is not an object (evaluating 'global.process.platform')
at
../node_modules/properties/lib/stringify.js(file:///node_modules/properties/lib/stringify.js:9:17)
at __webpack_require__(file:///src/webpack/bootstrap:750:0)

You can recreate the problem pretty simply.

1) Start a new app. (I used the default Angular drawer template.) 2) tns plugin add nativescript-app-sync 3) tns run ios --emulator

I’ll try to debug a bit and see if this is related to the new version, or maybe the type of app.

tjvantoll commented 4 years ago

Hmmm... the plugin works fine with the Hello World TypeScript template. Maybe it’s something about the Angular drawer template.

tjvantoll commented 4 years ago

Also fails with the Angular Hello World template. Looks like this is something specific to Angular... but I have no idea what :(

EddyVerbruggen commented 4 years ago

Hey @tjvantoll! I can reproduce this with your steps. Thanks for reporting it, I'll try to look into it asap.

EddyVerbruggen commented 4 years ago

Looks like the template recently changed this line

https://github.com/EddyVerbruggen/nativescript-app-sync/blob/27b4247e44827749808570e58ac85d4db65e82b7/demo-ng/tsconfig.tns.json#L4

to "module": "esNext" because of this change .. without that change there's no problem.

I'll have to look into making the plugin compatible with that change.

EddyVerbruggen commented 4 years ago

Please update to 1.0.7 - it's esNext compatible.

One note about version 1.0.6 and up: if you want the plugin to sync when hmr is enabled (like with tns run ios), you'll have to pass in enabledWhenUsingHmr: true as seen because AppSync and hmr bite each other (which is quite obvious if you think about it).

If you don't pass that in, this line will be executed.

tjvantoll commented 4 years ago

That fixed it 🎉 Thanks @EddyVerbruggen for the super fast response!

sebastien-bisson-dm commented 2 years ago

Hello,

We have encountered this issue recently with the latest version "2.0.2" on an ios ipad. " JS ERROR TypeError: undefined is not an object (evaluating 'global.process.platform')" with the following tack trace:

"Terminating app due to uncaught exception 'NativeScript encountered a fatal error: TypeError: undefined is not an object (evaluating 'global.process.platform') at ../node_modules/properties/lib/stringify.js(file:///app/vendor.js:110862:25) at webpack_require__(file:///app/runtime.js:75:34) at ../node_modules/properties/lib/write.js(file:///app/vendor.js:111076:36) at webpack_require(file:///app/runtime.js:75:34) at ../node_modules/properties/lib/index.js(file:///app/vendor.js:110039:32) at __webpack_require(file:///app/runtime.js:75:34) at file:///app/vendor.js:143089:39 at ../node_modules/tns-core-modules/ui/core/bindable/bindable.js(file:///app/vendor.js:143588:34) at webpack_require__(file:///app/runtime.js:75:34) at file:///app/vendor.js:142517:37 at ../node_modules/tns-core-modules/ui/builder/component-builder/component-builder.js(file:///app/vendor.js:142686:34) at webpack_require(file:///app/runtime.js:75:34) at file:///app/vendor.js:141978:46 at ../node_modules/tns-core-modules/ui/builder/builder.js(file:///app/vendor.js:142509:34) at __webpack_require(file:///app/runtime.js:75:34) at file:///app/vendor.js:128395:36 at ../node_modules/tns-core-modules/application/application.js(file:///app/vendor.js:128773:34) at webpack_require__(file:///app/runtime.js:75:34) at file:///app/vendor.js:95299:20 at ../node_modules/nativescript-angular/platform-common.js(file:///app/vendor.js:95618:34) at webpack_require(file:///app/runtime.js:75:34) at file:///app/vendor.js:95721:44 at ../node_modules/nativescript-angular/platform.js(file:///app/vendor.js:95764:34) at __webpack_require(file:///app/runtime.js:75:34) at ./main.ts(file:///app/bundle.js:2369:106) 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([native code]) at [native code]"

We are using nativescript 6 and here it is the tns doctor result: tns doctor ✔ Getting environment information

No issues were detected. ✔ Your ANDROID_HOME environment variable is set and points to correct directory. ✔ Your adb from the Android SDK is correctly installed. ✔ The Android SDK is installed. ✔ A compatible Android SDK for compilation is found. ✔ Javac is installed and is configured properly. ✔ The Java Development Kit (JDK) is installed and is configured properly. ✔ Xcode is installed and is configured properly. ✔ xcodeproj is installed and is configured properly. ✔ CocoaPods are installed. ✔ CocoaPods update is not required. ✔ CocoaPods are configured properly. ✔ Your current CocoaPods version is newer than 1.0.0. ✔ Python installed and configured correctly. ✔ The Python 'six' package is found. ✔ Xcode version 13.2.1 satisfies minimum required version 10. ✔ Getting NativeScript components versions information... ⚠ Update available for component nativescript. Your current version is 6.1.2 and the latest available version is 8.1.5. ⚠ Update available for component tns-core-modules. Your current version is 6.1.2 and the latest available version is 6.5.27. ⚠ Update available for component tns-android. Your current version is 6.1.2 and the latest available version is 6.5.3. ⚠ Update available for component tns-ios. Your current version is 6.5.2 and the latest available version is 6.5.4.

Did we miss something? Any help could be usefull.