Nativescript-angular: New nativescript+ng app created with version 2.2.1 of Nativescipt crashes on start

Created on 10 Sep 2016  路  11Comments  路  Source: NativeScript/nativescript-angular

I've just tried to create a new app with angular 2 support using these commands:

tns create ProvaNg --ng

tns platform add ios

tns run ios --emulator

but I'm getting these error when the app starts in the emulator:

Sep 10 21:08:38 Stefanos-MacBook-Pro ProvaNg[17597]: 1   0x100d14c67 -[TNSRuntime executeModule:]
Sep 10 21:08:38 Stefanos-MacBook-Pro ProvaNg[17597]: 2   0x100947702 main
Sep 10 21:08:38 Stefanos-MacBook-Pro ProvaNg[17597]: 3   0x1046a192d start
Sep 10 21:08:38 Stefanos-MacBook-Pro ProvaNg[17597]: 4   0x1
Sep 10 21:08:38 Stefanos-MacBook-Pro ProvaNg[17597]: file:///app/tns_modules/zone.js/dist/zone-node.js:670:21: JS ERROR Error: Could not find module 'timers'. Computed path '/Users/stefano/Library/Developer/CoreSimulator/Devices/0C77458C-EC39-4E4C-8FAD-8F19060E5199/data/Containers/Bundle/Application/77A25270-A3EC-4274-A4F8-84FA63CBD02A/ProvaNg.app/app/tns_modules/timers'.
Sep 10 21:08:38 Stefanos-MacBook-Pro com.apple.CoreSimulator.SimDevice.0C77458C-EC39-4E4C-8FAD-8F19060E5199.launchd_sim[11246] (UIKitApplication:org.nativescript.ProvaNg[0x92a4][17597]): Service exited due to signal: Segmentation fault: 11

I'm currently running nativescript 2.2.1.

I've got a previous app generated some days ago and everything worked but the package.json is quite different.

I've tried to copy the old dependencies but I still get the same error...

Here's the package.json file generated today:

{
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "org.nativescript.ProvaNg",
    "tns-ios": {
      "version": "2.2.1"
    }
  },
  "dependencies": {
    "@angular/common": "2.0.0-rc.4",
    "@angular/compiler": "2.0.0-rc.4",
    "@angular/core": "2.0.0-rc.4",
    "@angular/http": "2.0.0-rc.4",
    "@angular/platform-browser": "2.0.0-rc.4",
    "@angular/platform-browser-dynamic": "2.0.0-rc.4",
    "@angular/platform-server": "2.0.0-rc.4",
    "@angular/router": "3.0.0-beta.2",
    "@angular/router-deprecated": "2.0.0-rc.2",
    "nativescript-angular": "^0.3.0",
    "reflect-metadata": "^0.1.5",
    "rxjs": "5.0.0-beta.6",
    "tns-core-modules": "2.2.1",
    "zone.js": "^0.6.12"
  },
  "devDependencies": {
    "nativescript-dev-typescript": "^0.3.2",
    "typescript": "^1.8.10"
  }
}

I was running node 6 so I downgraded to the node 4 LTS version suggested on nativescript site but still without success...

Any suggestion I can use to fix the problem?

Most helpful comment

It appears the problem is in the zone.js npm module.

I am able to get working again with these steps:

rm -dr node_modules/zone.js/
npm install zone.[email protected]

All 11 comments

Same here.

I am also having the same problem on iOS and Android for my existing projects - at least when I clone them from git... I don't have any previously built workspaces to try those.

This sequence works:

tns create newtns
cd newtns
tns platform add android
tns run android --emulator

This sequence does not work:

tns create newtnsng --template angular
cd newtnsng
tns platform add android
tns run android --emulator

That results in this error on the Android screen:

java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException:
Error calling module function

Error: com.tns.NativeScriptException: Failed to find module: "timers", relative to: /app/tns_modules/
com.tns.Module.resolvePathHelper(Module.java:220)
com.tns.Module.resolvePath(Module.java:60)
com.tns.Runtime.runModule(Native Method)
com.tns.Runtime.runModule(Runtime.java:241)
com.tns.Runtime.run(Runtime.java:235)
com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:17)
android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
android.app.ActivityThread.handleBindApplication(ActivityThread.java:5361)
android.app.ActivityThread.-wrap2(ActivityThread.java)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528)
android.os.Handler.dispatchMessage(Handler.java:102)
android.os.Looper.loop(Looper.java:154)
android.app.ActivityThread.main(ActivityThread.java:6077)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
File: ", line: 1, column: 265

StackTrace:
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'', file:'/data/data/org.nativescript.newtnsng/files/app/tns_modules/zone.js/dist/zone-node.js', line: 670, column: 14
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'', file:'/data/data/org.nativescript.newtnsng/files/app/tns_modules/nativescript-angular/application.js', line: 2, column: 1
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'', file:'/data/data/org.nativescript.newtnsng/files/app/main.js', line: 3, column: 21
Frame: function:'require', file:'', line: 1, column: 266

at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5364)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: com.tns.NativeScriptException:
Error calling module function

Error: com.tns.NativeScriptException: Failed to find module: "timers", relative to: /app/tns_modules/
com.tns.Module.resolvePathHelper(Module.java:220)
com.tns.Module.resolvePath(Module.java:60)
com.tns.Runtime.runModule(Native Method)
com.tns.Runtime.runModule(Runtime.java:241)
com.tns.Runtime.run(Runtime.java:235)
com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:17)
android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
android.app.ActivityThread.handleBindApplication(ActivityThread.java:5361)
android.app.ActivityThread.-wrap2(ActivityThread.java)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528)
android.os.Handler.dispatchMessage(Handler.java:102)
android.os.Looper.loop(Looper.java:154)
android.app.ActivityThread.main(ActivityThread.java:6077)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
File: ", line: 1, column: 265

StackTrace:
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'', file:'/data/data/org.nativescript.newtnsng/files/app/tns_modules/zone.js/dist/zone-node.js', line: 670, column: 14
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'', file:'/data/data/org.nativescript.newtnsng/files/app/tns_modules/nativescript-angular/application.js', line: 2, column: 1
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'', file:'/data/data/org.nativescript.newtnsng/files/app/main.js', line: 3, column: 21
Frame: function:'require', file:'', line: 1, column: 266

at com.tns.Runtime.runModule(Native Method)
at com.tns.Runtime.runModule(Runtime.java:241)
at com.tns.Runtime.run(Runtime.java:235)
at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:17)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5361)
... 8 more

It appears the problem is in the zone.js npm module.

I am able to get working again with these steps:

rm -dr node_modules/zone.js/
npm install zone.[email protected]

I'm emulating on iOS and the above didn't work for my existing project. Even trying to remove and re-add the platform a few times didn't do it.

What I found worked is getting a fresh download of my existing project and doing:

npm install [email protected]
tns install

So if I do it before tns install, everything seems to be cool. Weird, but hey. In case anyone else needs to do it this way too.

Thanks ross-bradbury and SittingFox. Using 0.6.12 seemed to have fixed the issue for me too.

For anyone else who tripped on this, probably safer to change your 'package.json' and staple the zone.js version at 0.6.12.

-    "zone.js": "^0.6.12"
+    "zone.js": "0.6.12"

@diskshima Are you using Angular RC6. Because the above step doesn't seems to be work.

I just changed the project template to use a pinned zone.[email protected] until we figure a way to make this work with zone.[email protected]

The zone.js issue has been fixed for [email protected]

to: @hdeshev

do you want me to close the related zone.js issue?

@warren-bank I suggest we keep it open until the zone.js PR gets accepted, and we remove the need for our own fork.

you're the boss :) ..just let me know if there's anything that I can do to help

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bnussey picture bnussey  路  3Comments

sis0k0 picture sis0k0  路  3Comments

vakrilov picture vakrilov  路  3Comments

tsonevn picture tsonevn  路  3Comments

manojdcoder picture manojdcoder  路  3Comments