Development Workflow
CLI Basics
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:
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:
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):
nspackage-managersetnpm
nspackage-managersetyarn
nspackage-managersetyarn2# experimental
nspackage-managersetpnpm
- Previous
- Troubleshooting
- Next
- Running
Last updated: