模块“rxjs”没有导出成员“firstValueFrom”

Kri*_*909 7 node.js rxjs angularjs nestjs

App.service 文件如下所示:

import { Injectable } from '@nestjs/common';
import { HttpService } from '@nestjs/axios';
import { Observable, firstValueFrom } from 'rxjs';
// import { firstValueFrom } from 'rxjs';

@Injectable()
export class AppService {
  constructor(private httpService: HttpService) {}
  async getWeatherForecasts() {
    const url =
      'http://www.7timer.info/bin/api.pl?lon=113.17&lat=23.09&product=astro&output=json';
    const { data } = await firstValueFrom(this.httpService.get(url));
    return data;
  }
}
Run Code Online (Sandbox Code Playgroud)

Package.json 文件如下所示:

  "dependencies": {
    "@fmr-pr103625/nest-scaffold": "^1.5.5",
    "@nestjs/apollo": "^10.0.9",
    "@nestjs/axios": "0.0.7",
    "@nestjs/common": "^7.6.18",
    "@nestjs/core": "^7.6.18",
    "@nestjs/graphql": "^10.0.9",
    "@nestjs/platform-express": "^7.6.18",
    "apollo-server-express": "^3.6.7",
    "axios": "^0.27.2",
    "graphql": "^16.3.0",
    "graphql-tools": "^8.2.8",
    "isomorphic-fetch": "^3.0.0",
    "reflect-metadata": "^0.1.13",
    "rimraf": "^3.0.2",
    "rxjs": "^5.5.10",
    "rxjs-compat": "^6.6.7",
    "ts-morph": "^14.0.0"
  },
Run Code Online (Sandbox Code Playgroud)

————————————————————————————— --------------------

我无法从 rxjs 导入firstValueForm。

我已经尝试过的事情:

  1. 将 rxjs 的版本从 6 降级。

Sap*_*rsi 7

firstValueFrom引入Rxjs 7作为替代toPromise

RxJS 6.x 到 7.x 详细变更列表