diff --git a/file-system/file-system.ts b/file-system/file-system.ts index f9ebd41b6..f1f27fb60 100644 --- a/file-system/file-system.ts +++ b/file-system/file-system.ts @@ -442,10 +442,17 @@ export module knownFolders { export var currentApp = function (): Folder { if (!_app) { - var currentDir = __dirname; - var path = currentDir.substring(0, currentDir.indexOf("/tns_modules")); + const currentDir = __dirname; + const tnsModulesIndex = currentDir.indexOf("/tns_modules"); + + // Module not hosted in ~/tns_modules when bundled. Use current dir. + let appPath = currentDir; + if (tnsModulesIndex !== -1) { + // Strip part after tns_modules to obtain app root + appPath = currentDir.substring(0, tnsModulesIndex); + } _app = new Folder(); - _app[pathProperty] = path; + _app[pathProperty] = appPath; _app[isKnownProperty] = true; } @@ -465,4 +472,4 @@ export module path { } export var separator = getFileAccess().getPathSeparator(); -} \ No newline at end of file +}