找不到应用程序入口点文件。本机脚本

Application entry point file not found. nativescript

我创建了 Angular 2 nativescript 项目并在添加 android 平台后,我 运行 该项目在连接的 nexus 6p 中 android 版本 7.1.1 以及何时部署到设备的应用程序出现此错误:

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

知道如何解决这个错误吗?

更新:

我使用 tns create name --ng 创建项目,我只是 运行 使用 tns run android 命令。 package.js 文件:

{
    "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"
    }
}

您发布的 package.json 文件是错误的。

app 文件夹中应该还有一个。 它应该看起来像这样:

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

验证入口点文件是否存在(它必须是 .js 文件而不是 typescript 文件),你应该可以开始了。

问题出在节点版本上,我更新了节点,问题解决了!

入口点在angular.json

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

但是如果我们有任何编译错误,就会发生这样的错误,我在测试和子应用程序中有它,我在 tsconfig 中排除了它,现在它可以工作了

在我的例子中,它与我的 NativeScript CLI 版本有关。更新版本,问题解决。仅供参考,我在 angular-cli 7.3.6 和 NativeScript-cli 5.4.0(得到问题)更新到 NativeScript-cli 5.4.2 以解决问题。遇到类似问题的任何人,请尝试更新您的 NativeScript CLI 版本。