尽管将Typescript设置为2.0.10版,但“AppModule不是NgModule”错误

时间:2017-01-02 18:28:21

标签: angular angular-cli

我似乎有一个非常类似的问题,如herehere,使用Angular CLI 1.0.0-beta.24和Angular 2.4.1。

但是,将我的Typescript版本设置为2.0.10无效,运行ng build时仍然会得到'AppModule不是NgModule'。

这是我的package.json,我在某处使用了错误的依赖项或版本吗?

{
 "name": "my-project",
  "version": "0.1.0",
  "license": "",
  "angular-cli": {},
  "scripts": {
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "start": "ng serve",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor",
    "karma": "karma start karma.conf.js"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "2.4.1",
    "@angular/compiler": "2.4.1",
    "@angular/core": "2.4.1",
    "@angular/forms": "2.4.1",
    "@angular/http": "2.4.1",
    "@angular/platform-browser": "2.4.1",
    "@angular/platform-browser-dynamic": "2.4.1",
    "@angular/router": "3.4.1",
    "@angular/upgrade": "2.4.1",
    "core-js": "^2.4.1",
    "es6-promise": "^4.0.5",
    "es6-shim": "^0.35.2",
    "less": "~2.7.1",
    "lato-font": "2.0.0",
    "primeui": "^4.1.15",
    "primeng": "1.1.2",
    "reflect-metadata": "0.1.8",
    "rxjs": "5.0.2",
    "systemjs": "0.19.40",
    "zone.js": "0.7.4",
    "font-awesome": "4.7.0",
    "moment": "2.17.1",
    "chart.js": "2.4.0",
    "@types/google.visualization": "0.0.33"
  },
  "devDependencies": {
    "@types/jasmine": "^2.5.35",
    "@types/node": "^6.0.45",
    "concurrently": "^3.0.0",
    "es-module-loader": "^1.3.5",
    "angular-cli": "1.0.0-beta.24",
    "codelyzer": "2.0.0-beta.4",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-coverage": "^1.1.1",
    "karma-firefox-launcher": "^1.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.1.0",
    "karma-remap-istanbul": "^0.2.1",
    "karma-requirejs": "^1.1.0",
    "karma-spec-reporter": "0.0.26",
    "karma-systemjs": "^0.16.0",
    "requirejs": "^2.3.2",
    "webdriver-manager": "11.1.0",
    "typescript": "^2.0.10",
    "ts-helpers": "^1.1.2",
    "protractor": "4.0.14",
    "ts-node": "2.0.0",
    "tslint": "4.2.0"
  }
}

1 个答案:

答案 0 :(得分:1)

我使用了以下package.json:

{
  "name": "my-project",
  "version": "0.1.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "ng": "ng",
    "start": "ng serve",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update --standalone false --gecko false",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "2.4.1",
    "@angular/compiler": "2.4.1",
    "@angular/core": "2.4.1",
    "@angular/forms": "2.4.1",
    "@angular/http": "2.4.1",
    "@angular/platform-browser": "2.4.1",
    "@angular/platform-browser-dynamic": "2.4.1",
    "@angular/router": "3.4.1",
    "@angular/upgrade": "2.4.1",
    "core-js": "^2.4.1",
    "es6-promise": "^4.0.5",
    "es6-shim": "^0.35.2",
    "less": "~2.7.1",
    "lato-font": "2.0.0",
    "primeui": "^4.1.15",
    "primeng": "1.1.2",
    "reflect-metadata": "0.1.8",
    "rxjs": "5.0.2",
    "zone.js": "0.7.4",
    "font-awesome": "4.7.0",
    "moment": "2.17.1",
    "chart.js": "2.4.0",
    "@types/google.visualization": "0.0.33"
  },
  "devDependencies": {
    "@angular/compiler-cli": "2.4.1",
    "@types/jasmine": "^2.5.38",
    "@types/node": "^6.0.42",
    "concurrently": "^3.0.0",
    "es-module-loader": "^1.3.5",
    "angular-cli": "1.0.0-beta.24",
    "codelyzer": "2.0.0-beta.4",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "^1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-coverage": "^1.1.1",
    "karma-firefox-launcher": "^1.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "karma-requirejs": "^1.1.0",
    "karma-spec-reporter": "0.0.26",
    "requirejs": "^2.3.2",
    "typescript": "2.0.10",
    "ts-helpers": "^1.1.2",
    "protractor": "4.0.13",
    "ts-node": "1.2.1",
    "tslint": "4.0.2"
  }
}

请注意缺少的' ^'在打字稿版本中...
随着' ^'它仍然下载了2.1.4版本。