How to set up a mobile build server: step 3

  1. Introduction
  2. Server-side and client-side: (Optional) Create and configure an user on the build server
  3. Server-side: Install and configure the Android SDK
  4. Server-side: Install and configure cordova/ionic
  5. Client-side: Automate the build process

Server-side: Install and configure cordova/ionic

This step will be very short. We would like to install globally cordova and/or ionic without root privileges. By default, we need to use sudo with npm install -g (to install globally).
We can avoid these root command by changing the directory where the npm packages are installed.

Each command is executed on the server

Change npm packages installation directory

The new directory will be in your home and called .npm-packages. Create the directory and change the npm prefix by using

mkdir -p ~/.npm-packages
npm config set prefix "~/.npm-packages"

The executable files like cordova and ionic will now be in ~/.npm-packages/bin. We need to add this directory to your PATH to be able to use directly the command.

echo "export PATH=$PATH:~/.npm-packages/bin" >> ~/.${SHELL##*/}rc

You need to reload your shell configuration. You can do it by closing and reopening your terminal or by using the command

source ~/.${SHELL##*/}rc

Before continuing, check you have the directory ~/.npm-packages/bin in your PATH with

echo $PATH

Install cordova and ionic without root privileges

Now, we can install cordova and/or ionic. Here, we will install only cordova.

npm install -g cordova

What’s next?

It’s time to write our build script.

Go to the last part (coming soon). I’m working on several projects now, I don’t have time to write this last part.


You can download it here.

Leave a Reply

Your email address will not be published. Required fields are marked *