Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Ubuntu 16.04 - Setting Up Nativescript

Install Prerequisite

Install node 6.x LTS.


If you are running on a 64-bit system, install the runtime libraries for the ia32/i386 architecture.

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

Install the g++ compiler (you probably already have it)

sudo apt-get install g++

Install JDK 8 or a later stable official release. I recommend using the webupd8 repo rather than openjdk.


Download the command line tools for android, which should be at the bottom of this page).

wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip

Put the zip into a folder called android where you want to keep it before then extracting the zip file:

mkdir $HOME/android
mv sdk-tools-linux-*.zip $HOME/android/.
cd $HOME/android/
unzip sdk-tools-linux-*

Set android home and update your PATH. So you don't have to keep doing this manually, add these to your $HOME/.bashrc file.

export ANDROID_HOME=$HOME/android
export PATH=${PATH}:$ANDROID_HOME/tools
export PATH=${PATH}:$ANDROID_HOME/tools/bin
export PATH=${PATH}:$ANDROID_HOME/platform-tools

Update the ownership of these files to be owned by you.

sudo chown $USER:$USER -R $ANDROID_HOME

Install all packages for the Android SDK Platform 25, Android SDK Build-Tools 25.0.2 or later, Android Support Repository, Google Repository and any other SDKs that you may need. You can alternatively use the following command, which will install all required packages.

sudo $ANDROID_HOME/tools/bin/sdkmanager "tools" "platform-tools" "platforms;android-25" "build-tools;25.0.2" "extras;android;m2repository" "extras;google;m2repository"

This may take a while and won't show any progress status whilst its working away.

Install Nativescript CLI

Install the nativescript CLI You have a choice here, you can either run:

sudo npm install -g nativescript

Then get an ugly permission error fly past stating that

EACCES: permission denied, mkdir '/home/$USER/.local/share/.nativescript-cli'

... which can be resolved by running:

tns doctor

... or you could just run:

sudo npm install -g --unsafe-perm nativescript

If you don't use sudo, you will get the following error message: Missing write access to /usr/lib/node_modules.

Check Setup

You should now be able to check that everything installed correctly by running tns doctor, which should output:

NOTE: You can develop for iOS only on Mac OS X systems.
To be able to work with iOS devices and projects, you need Mac OS X Mavericks or later.

Your components are up-to-date: 
nativescript,tns-core-modules,tns-android,tns-ios

No issues were detected.

Conclusion

You've now installed Nativescript. You now probably want to set up an emulator before then building your first app.

References

Last updated: 16th August 2018
First published: 16th August 2018

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch