Next lesson playing in 5 seconds

  • Overview
  • Transcript

2.2 `tns` Commands

The NativeScript CLI is a big help when developing apps on this framework. It has a lot of commands that you need to know in order to develop apps. In this lesson, you’ll learn how to use the NativeScript CLI as well as how to create blank templates for JavaScript, TypeScript, or Angular 2.

Related Links

Useful commands

  • tns help
  • tns create <App Name> –template tns-template-blank
  • tns create <App Name> –template tns-template-blank-ts
  • tns create <App Name> –ng
  • tns create <App Name> –tsc
  • tns livesync <platform> –emulator –watch

2.2 `tns` Commands

As we have seen previously, NativeScripts URI provides a number of commands that we can use. In this video we are going to cover some of them which can be used during this course. The first command is the TNS which is a short hand for Telerik NativeScript and we are going to use it inside of NativeScript. TNS help will open a webpage and list all possible commands that you can use in the NativeScript CLI. TNS info, which shows the version information of NativeScript CLI, core module and runtimes. TNS create, create a new project. And the command is TNS create. And the name of the project, and also there is more to cover about this command which we will explain later. TNS platform command has multiple use cases. Like listing all platform currently installed with platform list or adding a platform with platform add. And finally, removing a platform with platform remove command. TNS install, Install our platform and dependencies described in the package dot json from the existing project. TNS run, runs the project on the connected physical devices if there is any or native emulators if configured. I've put the link in the resources section to show you how to configure an emulator on your machine. TNS debug, debug's a project on a connected device or emulator which we will see it shortly. TNS livesync, synchronizes all the latest changes in your project to the device. The syntax of the command is, TNS livesync, name of the platform --emulator --watch. If you want to start a new Angular 2 project, you can use TNS create command with --ng flag. This will create a sample, Hello World application in Angular 2. And if you want to create a TypeScript project, you can use --tsc flag. However the beauty of create command it resonates --template flag, where you can utilize a template as a starting point for an application. Such a template is tns-template-flag which creates a blank NativeScript application in your JavaScript Or tns -template-blank-ts for typescript version. In this demonstration, we are going to use JavaScript blank template as a starting point of the sample application. First, change it directly to this stop. And create a new blank project, tns create sampleapp --template tns-template-blank. And finally, add platform runtimes to the app, tns add ios, tns add android. In the next video, we are going to set up the editor and we use it throughout the course.

Back to the top