将nativescript添加到angular 6项目引发无法找到项目错误的构建目标

时间:2018-12-30 21:52:15

标签: angular6 angular2-nativescript

长期从事此工作。我有一个正在运行的angular 6项目,我也想添加nativescript。运行ng add @ nativescript / schematics后,它会安装并更新package.json。

但是随后在读取项目设置时失败:未能找到项目test-ng4-e2e的构建目标!

我的package.json看起来像这样:

{
    "name": "ANG6",
    "version": "6.0.0",
    "license": "Apache",
    "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build --prod",

        "test": "ng test",
        "test-ci": "TEST_CI=true ng test",
        "lint": "ng lint",
        "e2e": "ng e2e"
    },
    "private": true,
    "dependencies": {
        "@angular/animations": "^6.0.0",
        "@angular/common": "^6.0.0",
        "@angular/compiler": "^6.0.0",
        "@angular/core": "^6.0.0",
        "@angular/forms": "^6.0.0",
        "@angular/http": "^6.0.0",
        "@angular/platform-browser": "^6.0.0",
        "@angular/platform-browser-dynamic": "^6.0.0",
        "@angular/router": "^6.0.0",
        "@nativescript/schematics": "^0.4.0",
        "@ng-bootstrap/ng-bootstrap": "^2.0.0",
        "@ngx-translate/core": "^10.0.1",
        "@ngx-translate/http-loader": "^3.0.1",
        "chart.js": "^2.7.2",
        "core-js": "^2.5.5",
        "font-awesome": "^4.7.0",
        "ng-snotify": "^4.3.1",
        "ng2-charts": "^1.6.0",
        "ngx-smart-modal": "^7.0.0",
        "ngx-ui-loader": "^1.2.4",
        "rxjs": "^6.1.0",
        "yarn": "^1.6.0",
        "zone.js": "^0.8.26"
    },
    "devDependencies": {
        "@angular/cli": "6.0.0",
        "@angular/compiler-cli": "^6.0.0",
        "@angular/language-service": "^6.0.0",
        "@types/jasmine": "~2.8.6",
        "@types/jasminewd2": "~2.0.3",
        "@types/node": "^9.6.1",
        "codelyzer": "~4.2.1",
        "jasmine-core": "~3.1.0",
        "jasmine-spec-reporter": "~4.2.1",
        "karma": "~2.0.0",
        "karma-chrome-launcher": "~2.2.0",
        "karma-cli": "~1.0.1",
        "karma-coverage-istanbul-reporter": "^1.4.2",
        "karma-jasmine": "~1.1.1",
        "karma-jasmine-html-reporter": "^1.0.0",
        "protractor": "~5.3.0",
        "ts-node": "~5.0.1",
        "tslint": "~5.9.1",
        "typescript": "~2.7.0",
        "@angular-devkit/build-angular": "~0.6.0"
    }
}

和angular.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "test-ng4": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist",
            "index": "src/index.html",
            "main": "src/main.ts",
            "tsConfig": "src/tsconfig.app.json",
            "polyfills": "src/polyfills.ts",
            "assets": [
              "src/assets",
              "src/favicon.ico"
            ],
            "styles": [
              "node_modules/font-awesome/css/font-awesome.css",
              "src/styles/app.scss"
            ],
            "scripts": [
              "node_modules/chart.js/dist/Chart.js"
            ]
          },
          "configurations": {
            "production": {
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "test-ng4:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "test-ng4:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "test-ng4:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "karmaConfig": "./karma.conf.js",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "scripts": [
              "node_modules/chart.js/dist/Chart.js"
            ],
            "styles": [
              "node_modules/font-awesome/css/font-awesome.css",
              "src/styles/app.scss"
            ],
            "assets": [
              "src/assets",
              "src/favicon.ico"
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "test-ng4-e2e": {
      "root": "",
      "sourceRoot": "",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "./protractor.conf.js",
            "devServerTarget": "test-ng4:serve"
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "e2e/tsconfig.e2e.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "test-ng4",
  "schematics": {
    "@schematics/angular:component": {
      "prefix": "app",
      "styleext": "scss"
    },
    "@schematics/angular:directive": {
      "prefix": "app"
    }
  }
}

对于一个全新的项目,它可以正常工作,但不能与我现有的项目一起使用。

1 个答案:

答案 0 :(得分:0)

原来是版本问题。我尝试了0.3.0,它奏效了。也许更高版本也可以工作