Angular 角度4:模块未找到RxJs相关错误

Angular 角度4:模块未找到RxJs相关错误,angular,rxjs,reactivex,Angular,Rxjs,Reactivex,在构建Angular应用程序时,我遇到了很多这样的错误,下面就是第一个错误 ERROR in ./~/@reactivex/rxjs/dist/cjs/Rx.js Module not found: Error: Can't resolve './add/operator/filter' in '...\node_modules\@reactivex\rxjs\dist\cjs' @ ./~/@reactivex/rxjs/dist/cjs/Rx.js 70:0-32 @ ./~/@rea

在构建Angular应用程序时,我遇到了很多这样的错误,下面就是第一个错误

ERROR in ./~/@reactivex/rxjs/dist/cjs/Rx.js
Module not found: Error: Can't resolve './add/operator/filter' in 
'...\node_modules\@reactivex\rxjs\dist\cjs'
 @ ./~/@reactivex/rxjs/dist/cjs/Rx.js 70:0-32
 @ ./~/@reactivex/rxjs/index.js
 @ ./~/ri-api-client/dist/index.js
 @ ./src/app/core/api.service.ts
 @ ./src/$$_gendir/app/app.module.ngfactory.ts
 @ ./src/main.ts
 @ multi ./src/main.ts

我遗漏了什么?

根据您的错误消息,您的导入语句似乎不正确。它抱怨在node_modules/@reactivex中找不到东西,但它应该在node_modules/rxjs中查找

您的导入语句应如下所示:

import 'rxjs/add/operator/filter';
我也有类似的错误

`ERROR in ./src/app/shared/giphy/giphy.service.ts`
未找到模块:错误:无法解析“/Users/user1/opt/work/mine/development/ic/ic pms/pms ui/src/app/shared/giphy”中的“rxjs/add/operator/map”
ℹ 「wdm:未能编译。
src/app/shared/giphy/giphy.service.ts(16,35)中出错:错误TS2339:类型“Observable”上不存在属性“map”。

解决办法是
npm安装rxjs@6rxjs-compat@6--save

我发现angular正在服务中使用的文件夹中查找rxjs/add/operator/map,而不是从node_模块中查找

我通过在app.module.ts中导入rxjs解决了这个问题。尝试在app.module.ts中添加以下代码

import 'rxjs';

RXJS在版本6中更改了语法+

新的解决办法应该是:

从“rxjs/operators”导入{filter}

不是

导入'rxjs/add/operator/filter'

详情如下:

使用管道方法绘制
.map
只需添加--

.烟斗( 你的代码, 地图……)


它适合我。

如果使用angular 4+,您可能需要安装“rxjs compat”。

我所有的导入语句都是这样的。我刚刚检查了@reactivex文件夹,其中的@reactivex\rxjs\dist\cjs\add文件夹是空的,我想这就是它抱怨的原因。如何重新安装?所有内容都在rxjs文件夹下的wayDelete you node_modules目录下。确保package.json具有以下依赖项:“rxjs”:“^5.1.0”。然后再次运行npm安装。这个答案显示了您为
rxjs
保存的新导入格式!执行
npm安装后rxjs@6rxjs-compat@6--save
我现在收到以下错误:
/node\u modules/rxjs/\u esm5/index.js模块构建失败:错误:enoint:没有这样的文件或目录,请打开
import { map } from 'rxjs/operators';

.pipe(map(
      (response) => response.json()
 ))