πŸš€ 8.9 Released! β†’ ⚑️ New Node-API Engine Preview, πŸ“² ns widget ios, πŸ’… Tailwind v4 and more...
Read Announcement

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 ​

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:

bash
nsclean

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:

bash
nsdevices

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):

bash
nspackage-managersetnpm
nspackage-managersetyarn
nspackage-managersetyarn2# experimental
nspackage-managersetpnpm

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /