Setting up Nativescript on Ubuntu

damilola jolayemi
Damilola Jolayemi
Published in
3 min readOct 18, 2017

Recently I changed my development operation system from Windows to Ubuntu. And bit by bit, as project demands i have been setting things up. From laragon to valet, sublime text to Vscode, guis to terminal(terminator). The next part of the move was to set up Nativescript, and it happened yesterday.

Photo by Jared Brashier on Unsplash

If you are reading this and don’t know what NativeScript is, here is a snippet from the docs:

NativeScript is how you build cross-platform, native iOS and Android apps without web views. Use Angular, TypeScript or modern JavaScript to get truly native UI and performance while reusing the skills and the code from your web projects. Get 100% access to native APIs via JavaScript and reuse of packages from npm, CocoaPods and Gradle. Open source and backed by Progress.

Meaning: you can build native mobile applications for iOS and Android using web technologies. Read more here.

I found the official guide to do this good enough, but to make it work, i had to do things a little bit different. I share this steps in this post.

Let’s begin.

  1. Install Node.js or upgrade to the latest stable official release. The official doc recommends using Node.js v6.x.
  2. If your system is 64-bit based like mine, run the command below in your terminal. It will install the needed runtime libraries for the ia32/i386 architecture.
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 libstdc++6:i386

If you get “Unable to locate package lib32bz2–1.0” error after running the command above, try this:

sudo apt-get install lib32z1 lib32ncurses5 libbz2–1.0:i386 libstdc++6:i386

3. Install the G++ compiler.

Copysudo apt-get install g++

4. Install Java Development Kit 8.

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

5. Set the JAVA_HOME system environment variable.

export JAVA_HOME=$(update-alternatives --query javac | sed -n -e 's/Best: *\(.*\)\/bin\/javac/\1/p')

6. Download Android Studio from this page and install it.

7. Set the ANDROID_HOME system environment variable.

export ANDROID_HOME= Path to Android installation directory

I found mine in /home/<username>/Android/Sdk.

8. Open android studio > tools >android > sdk manager.

Install all packages for the Android SDK Platform 25, or later, Android Support Repository, Google Repository and any other SDKs that you may need.

9. Go here for instructions on how to create android emulators or android virtual devices(AVD) that you will use to test your applications.

10. Finally, install the NativeScript cli.

sudo npm install nativescript -g --unsafe-perm

After the installation of Nativescript cli completes, restart the terminal and run the command below to check if your system is configured properly.

tns doctor

If like me you get this error, “The ANDROID_HOME environment variable is not set or it points to a non-existent directory”. It’s because the ANDROID_HOME resets when you end the terminal session. To solve this, add the line below to your .bashrc file.

export ANDROID_HOME="/path/to/Android/Sdk/installation/directory"

Now you have Nativescript set up on your machine.

Go build something amazing.

If you are new to this, welcome, this is a good place to start.

--

--