node_modules / rxjs-compat / operator / shareReplay.d.ts(2,10)中的错误:错误TS2305:

时间:2019-02-02 12:51:11

标签: angular typescript rxjs angular-cli

我正在尝试将基本的角度骨架应用程序从Angle 5升级到Angle 6,这是我在尝试运行该应用程序时遇到的问题:

ERROR in node_modules/rxjs-compat/operator/shareReplay.d.ts(2,10): error TS2305: Module '"C:/newAdmin/testing-front-end/admin-fe/node_modules/rxjs/internal-compatibility/index"' has no exported member 'ShareReplayConfig'.

这是我的package.json:

{
 "name": "admin-fe",
 "version": "0.0.0",
 "scripts": {
 "ng": "ng",
 "start": "ng serve",
 "build": "ng build",
 "test": "ng test",
 "lint": "ng lint",
 "e2e": "ng e2e"
 },
 "private": true,
 "dependencies": {
   "@angular-devkit/core": "^7.3.0",
   "@angular/animations": "^6.1.0",
   "@angular/common": "^6.1.0",
   "@angular/compiler": "^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",
   "@ngrx/store": "^7.2.0",
   "angular-oauth2-oidc": "^5.0.2",
   "core-js": "^2.5.4",
   "moment": "^2.24.0",
   "rxjs": "6.3.3",
   "rxjs-compat": "^6.4.0",
   "zone.js": "~0.8.26"
  },
  "devDependencies": {
   "@angular-devkit/build-angular": "~0.7.0",
   "@angular/cli": "~6.1.3",
   "@angular/compiler-cli": "^6.1.0",
   "@angular/language-service": "^6.1.0",
   "@types/jasmine": "~2.8.6",
   "@types/jasminewd2": "~2.0.3",
   "@types/node": "~8.9.4",
   "codelyzer": "~4.2.1",
   "jasmine-core": "~2.99.1",
   "jasmine-spec-reporter": "~4.2.1",
   "karma": "~1.7.1",
   "karma-chrome-launcher": "~2.2.0",
   "karma-coverage-istanbul-reporter": "~2.0.0",
   "karma-jasmine": "~1.1.1",
   "karma-jasmine-html-reporter": "^0.2.2",
   "protractor": "~5.3.0",
   "ts-node": "~5.0.1",
   "tslint": "~5.9.1",
   "typescript": "^2.9.1"
 }
}

使用打字稿3.3.1时不会出现此错误,但我不能使用该错误,因为编译器将只允许我输入打字稿

我在这里可以采取什么步骤?

编辑:

我将rxjs和rxjs-compat版本都调整为6.3.3,但是现在出现以下错误:

ERROR in node_modules/@ngrx/store/src/store.d.ts(30,31): error TS2304: Cannot find name 'Extract'.

8 个答案:

答案 0 :(得分:18)

我遇到了同样的问题,我不得不降级rxjs-compat(6.3.3)使其与rxjs(6.3.3)保持一致,

在您的package.json中,它应该像:

-- Get the next order based on the last entry
DECLARE @newOrder INT = (SELECT TOP 1 DepartmentOrder FROM c.department WHERE dID = @dID ORDER BY DepartmentOrder DESC)


-- Add new department
    INSERT INTO c.department (dID,DepartmentID,DepartmentOrder)

    SELECT @dID,
           ParamValues.x1.value('departmentID[1]', 'int'),
           ISNULL(@newOrder,0)+1
    FROM @departments.nodes('/departments/department') AS ParamValues(x1)

如果您使用的是rxjs 6.4.0,则无需使用rxjs-compat,它提供了rxjs v6和v5之间的兼容性层。

所以我认为您可以直接使用来自'rxjs / operators'的import {shareReplay};

此处提供了有关运算符的更多信息:https://www.learnrxjs.io/

答案 1 :(得分:4)

我遇到"rxjs": "6.3.3","rxjs-compat": "6.4.0"的相同问题,尽管转移到版本^6.3.3,但错误仍然存​​在。只是一小部分。如果您的^中有rxjs-compat,则可能会引起问题。没有插入符号,即rxjs-compat": "6.3.3"对我有用。请参阅https://github.com/ReactiveX/rxjs/issues/4512。谢谢

答案 2 :(得分:4)

我在项目中遇到了相同的问题,即package.json文件中的rxjs和rxjs-compat版本不同,分别为rxjs =“ 6.3.3”和rxjs-compat =“ 6.4.0” 所以我只是通过以下命令降级了rxjs-compat版本:

  

npm install rxjs-compat@6.3.3 --s

对我有用。

答案 3 :(得分:0)

在package.json文件中编辑替换“ rxjs-compat”:“ ^ 6.4.0” =>“ rxjs-compat”:“ ^ 6.3.3”并运行命令

npm install

答案 4 :(得分:0)

我遇到了类似的问题。但是,当我在package.json中使用低于rxjs和rxjs-compat的版本时,此问题已解决。 --->“ rxjs”:“ 6.3.3”, --->“ rxjs-compat”:“ 6.3.3”

答案 5 :(得分:0)

我正在使用Angular 6,并且通过删除

解决了该问题

import 'rxjs/Rx';

来自我的代码。

答案 6 :(得分:0)

npm install rxjs-compat@6.3.3 --s

以上命令已修复我的问题

答案 7 :(得分:0)

我从rxjx / Rx导入Observable遇到了这个错误-从rxjs导入解决了此问题。

我的版本是

"rxjs": "~6.2.0",
"rxjs-compat": "^6.0.0",

我不需要更改它们,只需更改导入来源

从'rxjs / Rx'导入{Observable};

从'rxjs'导入{Observable};