I asked about it on the forum.
Please, ensure your title is less than 63 characters long and starts with a capital
letter.
I’m getting this error after updating my project.
Error: com.tns.NativeScriptException: Failed to find module: “.”, relative to: app/tns_modules/
If I open the generated javascript files to see where it is complaining I see this:
var _1 = require(".");
Android - problem
ios builds fine
tns --version
to fetch it)Cross-platform modules: (check the 'version' attribute in the
node_modules/tns-core-modules/package.json
file in your project)
"tns-core-modules": "^4.1.1",
Runtime(s): (look for the "tns-android"
and "tns-ios"
properties in the
package.json
file of your project)
"tns-ios": {
"version": "4.1.1"
},
"tns-android": {
"version": "4.1.3"
}
package.json
file of your"dependencies": {
"@angular/animations": "~6.0.6",
"@angular/common": "~6.0.6",
"@angular/compiler": "~6.0.6",
"@angular/core": "~6.0.6",
"@angular/forms": "~6.0.6",
"@angular/http": "~6.0.6",
"@angular/platform-browser": "~6.0.6",
"@angular/platform-browser-dynamic": "~6.0.6",
"@angular/router": "~6.0.6",
"async-await": "^0.1.40",
"lodash": "^4.17.10",
"moment": "^2.22.0",
"nativescript-angular": "^6.0.6",
"nativescript-audio": "^4.3.5",
"nativescript-drop-down": "^4.0.1",
"nativescript-orientation": "^2.2.0",
"nativescript-theme-core": "^1.0.4",
"nativescript-ui-listview": "3.5.9",
"nativescript-ui-sidedrawer": "^4.1.1",
"nativescript-unit-test-runner": "^0.3.4",
"nativescript-videoplayer": "^4.1.0",
"nativescript-webview-interface": "^1.4.2",
"nativescript-xmlobjects": "^1.1.4",
"node-sass": "^4.9.2",
"reflect-metadata": "~0.1.8",
"rxjs": "~6.0.0 || >=6.1.0",
"tns-core-modules": "^4.1.1",
"zone.js": "^0.8.26"
}
The best approach would be to get your code running in the NativeScript Playground and share the link with us, along with any additional details or steps to reproduce needed for examining the issue there.
This seems to be related to updating to 4.1.2 and my tsconfig file. Here is my ts.config.
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noEmitHelpers": false,
"noEmitOnError": false,
"skipLibCheck": true,
"lib": [
"es6",
"dom",
"es2015.iterable"
],
"baseUrl": ".",
"paths": {
"*": [
"./node_modules/tns-core-modules/*",
"./node_modules/*"
]
}
},
"exclude": [
"node_modules",
"platforms"
]
}
This is the first thrown error line in my generated javascript:
var _1 = require(".");
@bradrice try to reset the application by deleting node_modules
, platforms
and hooks
and then rebuilding again.
rm -rf node_modules platforms hooks
npm i
tns platform add android
tns run android
I tried doing those commands. I'm still getting the error and it won't display the android app in the emulator.
I've created a gist file of the error:
https://gist.github.com/bradrice/ea90202ed89aed7fc5a172ee6679a0dc
@bradrice from what I am seeing it seems that your tsconfig.json
is different from the newly generated ones (in the paths
section). Try the following command
npm i nativescript-dev-typescript@latest --save-dev
./node_modules/.bin/ns-upgrade-tsconfig
The paths section should look like this
"paths": {
"~/*": [
"app/*"
],
"*": [
"./node_modules/tns-core-modules/*",
"./node_modules/*"
]
}
I finally got my app to boot up. For some reason on the last update to 4.1.2 nativescript for android seems to not like importing from barrels.
I had to change my code from:
import { LoggerService, MyHttpGetService, AnimationService, PlatformService } from '.';
to:
import { LoggerService} from './logger.service';
import { MyHttpGetService } from './http.service';
import { AnimationService } from './animation.service';
import { PlatformService } from './platform.service';
The strange thing is it was working fine for ios, so the compilers work differently with regard to imports.
@bradrice try to reset the application by deleting
node_modules
,platforms
andhooks
and then rebuilding again.rm -rf node_modules platforms hooks npm i tns platform add android tns run android
Thanks, Worked for me!
I finally got my app to boot up. For some reason on the last update to 4.1.2 nativescript for android seems to not like importing from barrels.
I had to change my code from:
import { LoggerService, MyHttpGetService, AnimationService, PlatformService } from '.';
to:
import { LoggerService} from './logger.service'; import { MyHttpGetService } from './http.service'; import { AnimationService } from './animation.service'; import { PlatformService } from './platform.service';
The strange thing is it was working fine for ios, so the compilers work differently with regard to imports.
totally solved my problem, working with [email protected]
the error was just a Failed to find module: “.”, relative to: app/tns_modules/
Most helpful comment
@bradrice try to reset the application by deleting
node_modules
,platforms
andhooks
and then rebuilding again.