in Blog, Development

Building the NativeScript CLI from Source

So today I needed some features in NativeScript that had been committed to their repo, but had not been released via npm yet. I thought I’d be smart, clone the repo and just build it myself. ┬áIt wasn’t quite that simple, so here is the path I took to get it all working on OSX.

WARNING: Bleeding Edge Repos can break things.

Clone the repo

git clone
cd nativescript-cli

Grab the submodule(s)

git submodule init
git submodule update

If this were just a JS module, you could simply use npm to install it. But its not, this module contains TypeScript. Ah, a Gruntfile exists in the repo!

Install Grunt and its requirements (I already have the grunt-cli installed globally)

npm install grunt
npm install grunt-ts
npm install grunt-contrib-clean
npm install grunt-contrib-copy
npm install grunt-contrib-watch
npm install grunt-shell

Now if we run grunt, we will see that a JS and a MAP file is created for each TS file within the project.


To package up a zip (ex: nativescript-0.9.4-non-ci.tgz) you can install from, you can use

grunt pack

To install from that zip

sudo npm install -g nativescript-0.9.4-non-ci.tgz

WARNING: If you missed it above, worth restating: Bleeding Edge Repos can break things.

  1. A great one, Stephen, congrats!

    Just wanted to note an easer alternative for the installation of the dependent npm modules – `npm install`. Once you have grunt-cli installed globally, `npm install` would read the dependent packages from the package.config file and install them. Thus, that would eliminate the change of the sequence if the dependencies change.

    Erjan Gavalji

Comments are closed.