如何解决“无法找到模块:“ @ angular / compiler”错误?

时间:2018-10-30 19:28:49

标签: nativescript nativescript-angular

我已经升级到最新的本机脚本,打字稿并使用了angular。现在,无论我要编译到什么平台,只要尝试编译,都会出现此错误。

  

错误:com.tns.NativeScriptException:无法找到模块:“ @ angular / compiler”,相对于:app / tns_modules /

以下是我的 package.json依赖项:

    "dependencies": {
    "@angular/animations": "~6.1.0",
    "@angular/common": "~6.1.0",
    "@angular/core": "~6.1.0",
    "@angular/forms": "~6.1.0",
    "@angular/http": "~6.1.0",
    "@angular/platform-browser": "~6.1.0",
    "@angular/platform-browser-dynamic": "~6.1.0",
    "@angular/router": "~6.1.0",
    "async-await": "^0.1.40",
    "lodash": "^4.17.10",
    "moment": "^2.22.0",
    "nativescript-angular": "^6.1.0",
    "nativescript-audio": "^5.0.0",
    "nativescript-drop-down": "^4.0.1",
    "nativescript-orientation": "^2.2.0",
    "nativescript-theme-core": "^1.0.4",
    "nativescript-ui-listview": "3.5.9",
    "nativescript-ui-sidedrawer": "^4.1.1",
    "nativescript-unit-test-runner": "^0.3.4",
    "nativescript-videoplayer": "^4.1.0",
    "nativescript-webview-interface": "^1.4.2",
    "nativescript-xmlobjects": "^1.1.4",
    "node-sass": "^4.9.2",
    "reflect-metadata": "~0.1.8",
    "rxjs": "^6.0.0",
    "tns-core-modules": "^4.2.1",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.10.3",
    "@angular/cli": "^7.0.3",
    "@angular/compiler": "^6.1.10",
    "@angular/compiler-cli": "~6.1.0",
    "@types/lodash": "4.14.68",
    "@types/node": "~6.0.60",
    "babel-traverse": "^6.26.0",
    "babel-types": "^6.26.0",
    "babylon": "6.4.5",
    "jasmine-core": "^3.1.0",
    "karma": "^3.1.1",
    "karma-jasmine": "^1.1.1",
    "karma-nativescript-launcher": "^0.4.0",
    "lazy": "1.0.11",
    "nativescript-dev-sass": "^1.6.0",
    "nativescript-dev-typescript": "^0.7.4",
    "nativescript-dev-webpack": "^0.16.3",
    "tns-platform-declarations": "^3.4.1",
    "ts-node": "~3.3.0",
    "tslint": "^5.8.0",
    "typescript": "~2.7.2",
    "webpack": "^4.23.1",
    "webpack-dev-server": "^3.1.10"
  },

1 个答案:

答案 0 :(得分:2)

@angular/compiler应该在依赖关系下,而不是devDependencies。同样在最新版本中,它们使用@ngtools/webpack而不是实际的webpack软件包。

因此,最好将package.json与默认模板中的set_source_files_properties(${ASSET_FILES} PROPERTIES HEADER_FILE_ONLY ON ) 进行比较并进行必要的更改。