|
| 1 | +# Installing NativeScript |
| 2 | + |
| 3 | +In order to get started you will have to install the NativeScript command-line interface. |
| 4 | + |
| 5 | +## Install Node.js |
| 6 | + |
| 7 | +The NativeScript CLI is built on Node.js, and as such you need to have Node.js installed to use NativeScript. |
| 8 | + |
| 9 | +You can check if you have Node.js installed by opening up a terminal or command prompt on your development machine and executing |
| 10 | + |
| 11 | +```command |
| 12 | +node --version |
| 13 | +``` |
| 14 | + |
| 15 | +If you get an error, head to https://nodejs.org/ and download and install the latest "LTS" (long-term support) version for your development machine. |
| 16 | + |
| 17 | +<p class="tip"> |
| 18 | + If you’re on macOS and use [Homebrew](https://brew.sh/), you can alternatively install the Node.js LTS release by running `brew update`, to download the latest available updates and then `brew install node@6` in your terminal. |
| 19 | +</p> |
| 20 | + |
| 21 | +<p class="tip"> |
| 22 | + The NativeScript CLI supports a wide variety of Node.js versions, so if you already have Node.js installed you should be good to go. If, by chance, you’re running an unsupported version, the `tns doctor command` we’ll run momentarily will flag the problem so you can upgrade. |
| 23 | +</p> |
| 24 | + |
| 25 | +## Install the NativeScript CLI |
| 26 | + |
| 27 | +Open your terminal or command prompt and execute the following command to install the NativeScript CLI from npm, which is Node.js’ package manager: |
| 28 | + |
| 29 | +```command |
| 30 | +npm install -g nativescript |
| 31 | +``` |
| 32 | + |
| 33 | +<p class="tip"> |
| 34 | + If you are on a *NIX based system and receive an EACCESS error, you probably have to run the previous command with `sudo`, that is `sudo npm install -g nativescript` |
| 35 | +</p> |
| 36 | + |
| 37 | +After completing the setup you should have two commands available from your terminal or command prompt: |
| 38 | +- `tns` — which is short for Telerik NativeScript |
| 39 | +- `nativescript` |
| 40 | + |
| 41 | +The two commands are equivalent, so we'll stick with the shorter `tns`. |
| 42 | + |
| 43 | +You can verify the installation was successful by running `tns` in your terminal. You should see something like this: |
| 44 | +```terminal |
| 45 | +$ tns |
| 46 | +# NativeScript |
| 47 | +┌─────────┬─────────────────────────────────────────────────────────────────────┐ |
| 48 | +│ Usage │ Synopsis │ |
| 49 | +│ General │ $ tns <Command> [Command Parameters] [--command <Options>] │ |
| 50 | +│ Alias │ $ nativescript <Command> [Command Parameters] [--command <Options>] │ |
| 51 | +└─────────┴─────────────────────────────────────────────────────────────────────┘ |
| 52 | +``` |
| 53 | + |
| 54 | +## Install iOS and Android requirements |
| 55 | +When you build with NativeScript you're building truly native iOS and Android apps, and as such, you need to set up each platform you intend to build for on your development machine. To ease the pain of installing all of these requirements manually, the NativeScript CLI provides quick-start scripts for Windows and macOS that handle the necessary setup for you automatically. Let's look at how the work. |
| 56 | + |
| 57 | +<p class="tip"> |
| 58 | + Setting up your machine for native development can be tricky, especially if you're new to mobile development. If you get stuck, or if you have questions while going through these instructions, the [NativeScript community forum](http://forum.nativescript.org) is a great place to get help. |
| 59 | +</p> |
| 60 | + |
| 61 | +<p class="warning"> |
| 62 | + If you’re not comfortable with a script automatically installing dependencies on your development machine, or if you’re on Linux, refer to one of the advanced setup guides below for details on manually installing NativeScript’s iOS and Android dependencies. |
| 63 | + [Advanced setup: Windows](http://docs.nativescript.org/start/ns-setup-win), |
| 64 | + [Advanced setup: macOS](http://docs.nativescript.org/start/ns-setup-os-x), |
| 65 | + [Advanced setup: Linux](http://docs.nativescript.org/start/ns-setup-linux) |
| 66 | +</p> |
| 67 | + |
| 68 | +### Windows |
| 69 | + |
| 70 | +If you’re on Windows, copy and paste the script below into your terminal or command prompt and press Enter: |
| 71 | + |
| 72 | +```command |
| 73 | +@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://www.nativescript.org/setup/win'))" |
| 74 | +``` |
| 75 | + |
| 76 | +During installation you may need to accept a User Account Control prompt to grant the script administrative privileges. Also, be aware that the script downloads and installs some big dependencies — so it’s common for the script to take a while to complete. When the script finishes, close and reopen your command prompt. |
| 77 | + |
| 78 | +<p class="tip"> |
| 79 | + On Windows systems you can only use the NativeScript CLI to develop Android apps. This is because the NativeScript CLI uses Xcode to build iOS apps, which is only available on the macOS operating system. If you’re interested in building iOS apps on Windows, you may want to try out the public preview of [NativeScript Sidekick](https://www.nativescript.org/nativescript-sidekick). NativeScript Sidekick provides robust tooling for NativeScript apps, including a service that performs iOS and Android builds in the cloud, removing the need to complete these system requirements, and allowing you to build for iOS on Windows. |
| 80 | +</p> |
| 81 | + |
| 82 | +### macOS |
| 83 | + |
| 84 | +If you’re on a Mac, copy and paste the script below into your terminal and press Enter: |
| 85 | + |
| 86 | +```command |
| 87 | +ruby -e "$(curl -fsSL https://www.nativescript.org/setup/mac)" |
| 88 | +``` |
| 89 | + |
| 90 | +Much like the Windows script, the macOS script needs administrative access to run some commands using *sudo*; therefore, you may need to provide your password several times during execution. The macOS script also may take some time to complete, as it’s installing the dependencies for both iOS and Android development. When the script finishes, close and restart your terminal. |
| 91 | + |
| 92 | +## Verify the setup |
| 93 | + |
| 94 | +Once you've finished installing NativeScript and its dependencies, run the `tns doctor` command, which will check for any issues with your installation. |
| 95 | + |
| 96 | +If you see "No issues were detected" you are good to go! |
0 commit comments