使用ngx-datatable时无法解析rxjs /运算符

时间:2018-05-10 12:35:26

标签: angular typescript rxjs

我正在尝试将ngx-datatable合并到我的Angular-2应用程序中。我按照here提到的所有步骤进行了操作,但我收到以下错误:

  错误在./~/@swimlane/ngx-datatable/release/index.js       找不到模块:错误:无法解析&rxjs /运算符' in' C:\ Myproject \ node_modules \ @swimlane \ ngx-datatable \ release'        @ ./~/@swimlane/ngx-datatable/release/index.js 8:136-161        @ ./ClientApp/app/app.shared.module.ts        @ ./ClientApp/app/app.server.module.ts        @ ./ClientApp/boot.server.ts

这是我的package.json:

{
  "name": "MyProject",
  "private": true,
  "version": "0.0.0",
  "scripts": {
    "test": "karma start ClientApp/test/karma.conf.js"
  },
  "devDependencies": {
    "@angular/animations": "4.2.5",
    "@angular/cli": "^1.7.3",
    "@angular/common": "4.2.5",
    "@angular/compiler": "4.2.5",
    "@angular/compiler-cli": "4.2.5",
    "@angular/core": "4.2.5",
    "@angular/forms": "4.2.5",
    "@angular/http": "4.2.5",
    "@angular/platform-browser": "4.2.5",
    "@angular/platform-browser-dynamic": "4.2.5",
    "@angular/platform-server": "4.2.5",
    "@angular/router": "4.2.5",
    "@ngtools/webpack": "1.5.0",
    "@types/chai": "4.0.1",
    "@types/datatables.net": "^1.10.9",
    "@types/jasmine": "2.5.53",
    "@types/jquery": "^3.3.1",
    "@types/webpack-env": "1.13.0",
    "angular2-router-loader": "0.3.5",
    "angular2-template-loader": "0.6.2",
    "aspnet-prerendering": "^3.0.1",
    "aspnet-webpack": "^2.0.1",
    "awesome-typescript-loader": "3.2.1",
    "bootstrap": "3.3.7",
    "chai": "4.0.2",
    "css": "2.2.1",
    "css-loader": "0.28.4",
    "es6-shim": "0.35.3",
    "event-source-polyfill": "0.0.9",
    "expose-loader": "0.7.3",
    "extract-text-webpack-plugin": "2.1.2",
    "file-loader": "0.11.2",
    "html-loader": "0.4.5",
    "isomorphic-fetch": "2.2.1",
    "jasmine-core": "2.6.4",
    "jquery": "^3.2.1",
    "json-loader": "0.5.4",
    "karma": "1.7.0",
    "karma-chai": "0.1.0",
    "karma-chrome-launcher": "2.2.0",
    "karma-cli": "1.0.1",
    "karma-jasmine": "1.1.0",
    "karma-webpack": "2.0.3",
    "preboot": "4.5.2",
    "raw-loader": "0.5.1",
    "reflect-metadata": "0.1.10",
    "rxjs":  "^5.5.5",
    "style-loader": "0.18.2",
    "to-string-loader": "1.1.5",
    "typescript": "2.4.1",
    "url-loader": "0.5.9",
    "webpack": "2.5.1",
    "webpack-hot-middleware": "2.18.2",
    "webpack-merge": "4.1.0",
    "zone.js": "0.8.12"
  },
  "dependencies": {
    "@swimlane/ngx-datatable": "^12.0.0",
    "angular-datatables": "^5.0.0",
    "angular2-datatable": "^0.6.0",
    "datatables.net": "^1.10.16",
    "datatables.net-dt": "^1.10.16",
    "json-stringify-safe": "^5.0.1",
    "ng2-toasty": "^4.0.3",
    "raven-js": "^3.24.2"
  }
}

如您所见,它已经有了rxjs参考。所以,我真的不确定还有什么办法可以解决这个问题。如果您希望我向您展示任何其他文件,请告诉我。

2 个答案:

答案 0 :(得分:1)

更新ngx-datatable版本12.0.0以使用角度6. Angular 6现在使用rxjs> 6(参见this blogpost),这意味着ngx-datatable可能也在使用rxjs > 6(见this issue)。您仍在引用rxjs 5.5.0,这在导入方面有点不同,这可能是为什么ngx-datatable(需要rxjs 6)无法在rxjs 5.5.0文件夹中找到所需的东西(我认为是rxjs) /运算符在rxjs中不再存在6)。

所以为了让事情有效,你可能不得不降级到更低版本的ngx-datatable,它仍然适用于rxjs 5.5.0,或者我强烈推荐,将你的角度版本和rxjs版本更新到版本6。这当然可能会引发更多错误,但从长远来看,这应该是可行的方法。

答案 1 :(得分:0)

在完全不同的情况下,我有相同的错误。找到之前,我尝试了很多事情:

npm install rxjs@6 rxjs-compat@6 --save

好像我一般需要一个最近的rxjs,但在安装升级了其他节点库的东西之后也需要一个rxjs兼容性层。