Import modules using absolute paths



Is there any way to import absolute modules? For instance today I have some imports libe this:

import { ModuleName } from './../../../module-filename'

In big projects, where you end up having many nested folder to organize a large amount of files this approach is not good, specially if you have to reorganize some files and folders.

Typescipt has the baseUrl compiler option to import modules with the absolute path. But it seems that {N} is ignoring this option.

Does anyone know if this is supported or if is there any other way of doing this?


NativeScript follows Node’s Module specification, so whatever you can do there, you can do in NativeScript too.

One thing that NS has in addition is ~/ which will resolve to app/tns_modules.

Developers in this SO thread share a few good options: