Nativescript-angular: Running ng-sample - fails with "Cannot read property 'version' of undefined" ?

Created on 13 Jan 2016  ยท  7Comments  ยท  Source: NativeScript/nativescript-angular

I'd like to contribute more on this project but want to make sure I can run everything properly.
After following README verbatim, preparing everything, and then try to run the sample with:

env WEBPACK_BUILD=1 tns emulate ios --timeout 500 --device "com.apple.CoreSimulator.SimDeviceType.iPhone 6"

I get this:

Executing before-prepare hook from /Users/nathan/Documents/github_projects/nativescript-stuff/nativescript-angular/ng-sample/hooks/before-prepare/10-copy-renderer.js
Executing before-prepare hook from /Users/nathan/Documents/github_projects/nativescript-stuff/nativescript-angular/ng-sample/hooks/before-prepare/20-nativescript-dev-typescript.js
Found peer TypeScript 1.7.5
Cannot read property 'version' of undefined
# emulate ios
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Usage   โ”‚ Synopsis                                                                                                      โ”‚
โ”‚ General โ”‚ $ tns emulate ios [--path <Directory>] [--device <Device Name>] [--available-devices] [--release] [--timeout] โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Builds the specified project and runs it in the native iOS Simulator.

### Options

    * --available-devices - Lists all available device type identifiers for the current Xcode.
    * --release - If set, produces a release build. Otherwise, produces a debug build.
    * --path - Specifies the directory that contains the project. If not specified, the project is searched for in the current directory and all directories above it.
    * --device - Specifies the name of the iOS Simulator device on which you want to run your app. To list the available iOS Simulator devices, run $ tns emulate ios --available-devices
    * --timeout - Sets the number of seconds that the NativeScript CLI will wait for the iOS Simulator to start before quitting the operation and releasing the console. The value must be a positive integer. If not set, the default timeout is 90 seconds. 

### Attributes

    * <Device Name> is the name of the iOS Simulator device on which you want to run your app as listed by $ tns emulate ios --available-devices 

Most helpful comment

I sometimes get this error due to corrupted files in my platform folder. tns platform remove ... + tns platform add ... usually fixes it.

All 7 comments

Same issue when not using webpack env:

tns emulate ios --timeout 500 --device "com.apple.CoreSimulator.SimDeviceType.iPhone 6"

I sometimes get this error due to corrupted files in my platform folder. tns platform remove ... + tns platform add ... usually fixes it.

That was exactly it @hdeshev thanks! Works great now :+1:

The would be

tns platform remove ... 
followed by
tns platform add ... 

I'm tired of doing:
platform remove /platform add
:(

I noticed on mine that when installing tns-ios it wasn't creating a version in my package.json.

I went ahead and added the latest version in the same format as the android version, which should look like this.

"nativescript": {
        "id": "org.nativescript.Groceries",
        "tns-android": {
            "version": "3.1.1"
        },
        "tns-ios": {
            "version": "3.1.0"
        }
    },

After that it ran fine.

I seem to have to run tns platform remove followed by tns platform run an awful many times...

Was this page helpful?
0 / 5 - 0 ratings