Code share between applications


Hi guys,

maybe the answer is just obvious, trying for couple of days to figure out how we can share common components between different nativescript applications (angular2).

I mean, not just services and UI components but actually pages - login, settings, some base entities used by more mobile applications we’re working on.

It kinda looks wrong to copy/paste the same thing over and over again, any idea on how this could be achieved?



Sorry, I don’t have an answer…
I was actually wondering the exact same thing (except for the angular part)!

My situation is this:

I use NativeScript (3.0 now) with TypeScript (but not Angular (yet)). I am very much a novice, but getting some good results.
While learning, and creating various projects, I have started to build up a “app/shared” directory full of useful utilities. However, I need to constantly sync between my various projects’ app/shared directories.

Ideally, I would like to have these directories as ONE directory, away from app/., and away from any project directory.

What’s the recommended way to get this done?


Have either of you attempted to create your own package, similar to what you might install via npm install?

Though I haven’t tried this personally, I would think that you would be able to share code in this manner…

I hope this helps,



This is #1 the best idea, but I think the problem is that you need to pay to have private npm repos. Could also make nativescript plugins and “tns plugin add …/…/plugins/myplugin” perhaps? Like shared local plugins?


I haven’t tried it with private repos so not sure how authentication works but I use github to pull in repos.

For example from my package.json

"nativescript-google-maps-sdk": "randy-johnson/nativescript-google-maps-sdk",

A quick google search selecting the first result shows

which shows how to use bitbucket private repos in your package.json

I think this would accomplish what you need. yes?


Thanks guys, we were already using our own package and installing it from an archive (npm pack) using tns plugin add works just fine if you don’t want to publish it somewhere - sinopia works great if you need to host private repos.

Our problem was specific to angular components, particularly to usage of templateUrl and styleUrls. Normally those paths are relative to the application root folder only when doing that on a ‘plugin’ package and install that the referenced files are not found - the easiest way to solve it was to reference those considering the plugin path like tns_modules/mymodule/path_to_file.html instead of initial ‘path_to_file.html’.

Marian Edu

Acorn IT
+40 740 036 212