【问题标题】:Error while creating components with Nativescript cli使用 Nativescript cli 创建组件时出错
【发布时间】:2019-10-24 14:47:03
【问题描述】:

我正在使用 NativeScript 构建一个全新的应用程序,但我在使用 nativescript cli 创建组件/服务/等时遇到问题。我只是不断得到:

Error: Invalid rule result: Instance of class Promise.
    at t.project (/usr/local/lib/node_modules/nativescript/node_modules/@nativescript/schematics-executor/dist/index.js:250:1038)
...

我查看了这种错误,所有的修复方法是使用相同版本的 @angular/cli 和 @schemics/angular,然后删除 package-lock.json 和 node_modules,但这些都不起作用。 下面是 package.json

{
  "nativescript": {
    "id": "com.domain.app",
    "tns-android": {
      "version": "6.0.2"
    },
    "tns-ios": {
      "version": "6.0.2"
    }
  },
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "repository": "<fill-your-repository-here>",
  "scripts": {
    "lint": "tslint \"src/**/*.ts\""
  },
  "dependencies": {
    "@angular/animations": "~8.2.0",
    "@angular/common": "~8.2.0",
    "@angular/compiler": "~8.2.0",
    "@angular/core": "~8.2.0",
    "@angular/forms": "~8.2.0",
    "@angular/platform-browser": "~8.2.0",
    "@angular/platform-browser-dynamic": "~8.2.0",
    "@angular/router": "~8.2.0",
    "nativescript-angular": "~8.2.0",
    "nativescript-angular-cli": "^0.1.9",
    "nativescript-theme-core": "~1.0.6",
    "nativescript-ui-sidedrawer": "~7.0.0",
    "reflect-metadata": "~0.1.12",
    "rxjs": "^6.4.0",
    "tns-core-modules": "~6.0.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular/cli": "^8.2.0",
    "@angular/compiler-cli": "8.2.0",
    "@nativescript/schematics": "^0.7.2",
    "@ngtools/webpack": "~8.2.0",
    "@schematics/angular": "^8.2.0",
    "codelyzer": "~4.5.0",
    "nativescript-dev-webpack": "~1.1.0",
    "node-sass": "^4.7.1",
    "tslint": "~5.11.0",
    "typescript": "~3.5.3"
  },
  "gitHead": "42f2a6a9c94eaf9c68d2a41e0daaa1a2544bc28f",
  "readme": "NativeScript Application"
}

还有什么我可以做的吗?大家有没有看到什么奇怪的东西?这只是一个全新的应用程序。而且我已经用 Nativescipt(旧版本)构建了两三个应用程序,没有这样的问题。

【问题讨论】:

标签: angular nativescript nativescript-angular tns


【解决方案1】:

我只需使用 ng 命令就可以使用它,我知道你说这是用于 nativescript,但对我来说,ng 命令也会生成 Nativescript dns 文件,如果它是共享的,或者如果它是原生的,那么它是正确的,所以只需尝试

ng generate c name

【讨论】:

    猜你喜欢
    • 2017-02-08
    • 2021-01-24
    • 2020-01-16
    • 1970-01-01
    • 2017-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-15
    相关资源
    最近更新 更多