8.8 released—CSS Media Query support, SF Symbols and much more...
Learn more

When working with NativeScript, you will often interact with the NativeScript CLI. The CLI is self-documented, so you can always run ns --help or ns <command> --help to view available commands, flags and descriptions.

This page is a quick reference for useful development commands, but it's not meant to be an exhaustive list of all the commands.

The following workflows have their dedicated pages with further information:


Cleaning a single project

When you're installing plugins with native dependencies or updating runtime versions, it's a good practice to perform a clean build. This helps ensure everything fits together correctly. If you're dealing with mysterious build errors, they might disappear after a clean build.

To clean, run this command from your project's root directory:

ns clean

Running ns clean removes the node_modules, hooks, and platforms directories and the package-lock.json file. You can customize what's cleaned in the nativescript.config.ts.

Cleaning multiple projects

If you have multiple projects in a directory, you can run ns clean in it, and it will scan for any valid NativeScript projects in sub-directories and then prompt you to choose the ones to clean.


Listing connected devices

To list all connected devices (both physical and virtual), run:

ns devices

Example output:

| # | Device Name    | Platform | Device Identifier                    | Type     | Status    | Connection Type |
| - | -------------- | -------- | ------------------------------------ | -------- | --------- | --------------- |
| 1 | Pixel 4 API 33 | Android  | emulator-5554                        | Emulator | Connected | Local           |
| 2 | generic_device | Android  | XXXXXXXXXXXXXX                       | Device   | Connected | USB             |
| 3 | iPhone 14 Pro  | iOS      | XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX | Emulator | Connected | Local           |

Setting the default package manager

To set the default package manager that the CLI uses (unless overridden in nativescript.config.ts):

ns package-manager set npm
ns package-manager set yarn
ns package-manager set yarn2 # experimental
ns package-manager set pnpm