Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Getting Started with NativeScript

You're reading from   Getting Started with NativeScript Explore the possibility of building truly native, cross-platform mobile applications using your JavaScript skill—NativeScript!

Arrow left icon
Product type Paperback
Published in Jan 2016
Publisher
ISBN-13 9781785888656
Length 168 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Nathanael J. Anderson Nathanael J. Anderson
Author Profile Icon Nathanael J. Anderson
Nathanael J. Anderson
Arrow right icon
View More author details
Toc

The NativeScript command line

Now, before we get to the creating a project part, let us have an overview of the commands available from the new nativescript command you just installed. If you forget any of these, you can easily type nativescript alone without any parameters to see a help screen at a console window, or type nativescript /? for a help screen in your browser.

NativeScript commands

These are just some of the most commonly used valid commands for the nativescript command. Several of these we will be covering as we progress in the book.

Command line

Description

nativescript --version

This returns the version of the nativescript command. If you are running an older version, then you can use npm to upgrade your nativescript command like this: npm install -g nativescript.

nativescript create <your project name>

This creates a brand new project.

nativescript platform add <platform>

This adds a target platform to your project.

nativescript platform list

This shows you what platforms you are currently targeting.

nativescript platform remove <platform>

This command is normally not needed, but if you are messing with the platform directory and totally mess up your platform, you can remove and then add it back. Please note this deletes the entire platform directory, so if you have any specific customizations to your Android manifest or iOS Xcode project file, you should back it up before running the remove command.

nativescript platform update <platform>

This is actually a pretty important command. NativeScript is still a very active project under a lot of development. This command upgrades your platform code to the latest version, which typically eliminates bugs and adds lots of new features. Please note this should also be done with an upgrade of the common JavaScript libraries as most of the time, they also are typically in sync with each other.

nativescript build <platform>

This builds the application for that platform.

nativescript deploy <platform>

This builds and deploys the application to a physical or virtual device for that platform.

nativescript emulate <platform>

This builds and deploys the application to an emulator.

nativescript run <platform>

This builds, deploys, and starts the application on a physical device or an emulator. This is the command you will use the majority of the time to run your application and check out the changes.

nativescript debug <platform>

This builds, deploys, and then starts the application on a physical device or an emulator in debug mode. This is probably the second most used command.

nativescript plugin add <plugin>

This allows you to add a third-party plugin or component. These plugins typically include JavaScript based code, but occasionally, they might also contain an actual compiled Java or ObjectiveC library.

nativescript livesync - -watch

This allows you to have the nativescript command watch for changes and automatically push them to the device. This is probably the third most used command if you are not using a better third-party LiveSync system. We call it LiveSync because it automatically syncs all your changes directly to the device in real time, without you having to rebuild the application. This speeds up your development of an application drastically.

nativescript doctor

This allows you to run some diagnostic checks on your environment if the nativescript command does not appear to be working.

nativescript install

This will (re)install any dependencies listed in your package.json file. The package.json file is typically modified by the plugin or library add function, so this is used typically to reinstall the plugins or libraries in the event you add a new platform or reinstall one.

nativescript test [ init | <platform> ]

This allows you to create or run any tests for your application. Using init will initialize the test framework for the application. Then, you just use the platform to run the tests on that platform.

Now that we have described some of the commands, let's use them to create your first mobile app via the nativescript command tool.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime