NOTE: NativeScript apps do not run on webview.
To start developing NativeScript apps, there are few set ups that needs to be don. Technically, the NativeScript playground and local environment set up are the two ways in getting started.
Due to the limitations of the playground, this tutorial will focus on using the local environment which gives you access to native device api, npm packages, gradle and open source utilities.
Time to prepare the grounds for NativeScript development.
STEP 1: Install Node.js
Node.Js needs to be installed since NativeScript CLI relies on it to function. First check weather Node is on the local system by bringing up your terminal and executing the command node -v (short form for node –version). The ‘dash’ here is double not single.
If no error pop-up, node is installed else, head over to nodejs.org, download and install the latest ‘LTS’ (Long-term support). Restart the terminal after the process.
Mac users might need to configure path if getting erros after installation.
STEP 2: Install NativeScript CLI
Launch command prompt and execute ‘npm install -g nativescript’
npm install -g nativescript
The two key words here to explain: npm stands for node package manager, -g for global which gives the opportunity to create NativeScript apps anywhere on the local manchine.
For macOS, run ‘sudo npm install -g nativescript’
sudo npm install -g nativescript
You might also want to fix npm permissions. This will ease affaires as you will no longer need admin rights to globally install npm packages.
STEP 3: Verify Installation
Open the terminal or command prompt and run ‘tns’ which stand for Telerik NativeScript. These commands are made available right after installing NativeScript CLI.
Running tns or Telerik NativeScript should give below results if all things goes on well.
If you made it this far, you are good to go and can start developing native apps with NativeScript. More over, in order to run the apps on an emulator, android and ios requirements needs to be installed as described below.
STEP 4: Installing IOS and Android Requirements
This process can be don in two ways. Firstly by using NativeScript CLI. The CLI provide and easy way to completly set everything up with just a command.
This time launch your terminal or command prompt as an administrator and paste in the code below.
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://www.nativescript.org/setup/win'))"
It will take some time to finish up as some large dependencies will be downloaded and installed. Alongside you may have to accept some prompt to fully grant the script access to continue the process.
STEP 5: Verify Installation
Run ‘tns doctor’ in the terminal. Congratulations if you see ‘No issues were detected’
Check NativeScript documentation for the second option to mannually install dependencies. Chances are that some dependencies might already exist on the local manchine of which there won’t be any need to reinstall.
Coming up: Creating and running first NativeScript app