Application entry point file not found. nativescript

5.3k views Asked by At

I create Angular 2 nativescript project and after adding android platform, i run the project in a connected nexus 6p with android version 7.1.1 and when app deployed to the device i got this error:

An uncaught Exception occurred on "main" thread.
java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Application entry point file not found. Please specify the file in package.json otherwise make sure the file index.js or bootstrap.js exists.\nIf using typescript make sure your entry point file is transpiled to javascript.
 at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5406)
 at android.app.ActivityThread.-wrap2(ActivityThread.java)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:154)
 at android.app.ActivityThread.main(ActivityThread.java:6119)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: com.tns.NativeScriptException: Application entry point file not found. Please specify the file in package.json otherwise make sure the file index.js or bootstrap.js exists.\nIf using typescript make sure your entry point file is transpiled to javascript.
 at com.tns.Module.bootstrapApp(Module.java:337)
 at com.tns.Runtime.run(Runtime.java:508)
 at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:17)
 at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
 at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5403)
 ... 8 more
Caused by: com.tns.NativeScriptException: Failed to find module: "./", relative to: app//
 at com.tns.Module.resolvePathHelper(Module.java:159)
 at com.tns.Module.bootstrapApp(Module.java:335)
 ... 12 more

any idea how can i solve this error?

Update:

i create the project with tns create name --ng and i just run it with tns run android command. the package.js file:

{
    "description": "NativeScript Application",
    "license": "SEE LICENSE IN <your-license-filename>",
    "readme": "NativeScript Application",
    "repository": "<fill-your-repository-here>",
    "nativescript": {
        "id": "org.nativescript.Bazim",
        "tns-android": {
            "version": "2.4.1"
        }
    },
    "dependencies": {
        "@angular/common": "2.2.1",
        "@angular/compiler": "2.2.1",
        "@angular/core": "2.2.1",
        "@angular/forms": "2.2.1",
        "@angular/http": "2.2.1",
        "@angular/platform-browser": "2.2.1",
        "@angular/platform-browser-dynamic": "2.2.1",
        "@angular/router": "3.2.1",
        "nativescript-angular": "1.2.0",
        "nativescript-theme-core": "^0.2.1",
        "reflect-metadata": "~0.1.8",
        "rxjs": "5.0.0-beta.12",
        "tns-core-modules": "2.4.3",
        "typescript": "~2.0.10",

    },
    "devDependencies": {
        "babel-traverse": "6.21.0",
        "babel-types": "6.21.0",
        "babylon": "6.14.1",
        "lazy": "1.0.11",
        "nativescript-dev-android-snapshot": "^0.*.*",
        "nativescript-dev-typescript": "^0.3.2",
        "typescript": "~2.0.10",
        "zone.js": "~0.6.21"
    }
}
4

There are 4 answers

0
Pourya8366 On BEST ANSWER

The problem was from node version, i updated the node and the problem solved!

6
Aaron Ullal On

The package.json file you posted is the wrong one.

There should be another one inside the app folder. It should look something likes this :

{
  "name": "name",
  "main": "app.js", //THIS IT THE ENTRYPOINT
  "version": "X.X.X",
  "author": {
    "name": "Name",
    "email": "[email protected]"
  },
  "description": "some desc!",
  "repository": {
    "url": "https://github.com/yourrepo"
  }
}

Verify that the entry point file exists (it has to be a .js file and not a a typescript file) and you should be good to go.

0
user3844710 On

the entry point is defined in angular.json

"architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/output",
            "index": "src/index.html",
            "main": "src/main.ts",

but error like this can happen if we have any compile errors, I had it with tests and sub application, I excluded it in tsconfig and now it works

0
Faddablack On

In my case it was related to my NativeScript CLI version. Updated the version and the issue was solved. Just for reference I was at angular-cli 7.3.6 and NativeScript-cli 5.4.0 (got the issue) updated to NativeScript-cli 5.4.2 to solve the issue. Anyone facing the similar issue, try updating your NativeScript CLI version.