打字稿:如何解决'rxjs/Rx 没有导出成员'SubscriptionLike'

新手上路,请多包涵

我试图在此处遵循此示例 https://www.youtube.com/watch?v=gxCu5TEmxXE ,但是在执行 tsc -p 时,出现错误。有什么我需要进口的吗?

错误:

node_modules/@angular/common/src/location/location.d.ts(1,10): error TS2305: Module '"...functions/node_modules/rxjs/Rx"' has no exported member 'SubscriptionLike'.

文件

import "zone.js/dist/zone-node";
import * as functions from "firebase-functions";
import * as express from "express"
import { renderModuleFactory } from "@angular/platform-server"
import * as fs from "fs"

const document = fs.readFileSync(__dirname + "/dist-server/index.html", "utf8");
const AppServerModuleNgFactory = require(__dirname + "/dist-server/main.bundle");

const app = express();
app.get("**", (req, res) => {
    const url = req.path;
    renderModuleFactory(AppServerModuleNgFactory, { document, url }).then(html => {
        res.send(html);
    });
});
exports.post = functions.https.onRequest(app);

配置

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es2015",
    "rootDir": ".",
    "outDir": "../functions"
  },
  "files": [
    "index.ts"
  ]
}

原文由 Relm 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 403
1 个回答

关注后我遇到了同样的问题

按照 djamware 的本教程

经过大量搜索,我发现 Angular 6 不支持通过本教程中的说明安装的 Rxjs 包。

Angular 6 不适用于 RxJS 5.5,但适用于 RxJS 6。

 npm i rxjs@6

在 cli 中运行上面的命令,这应该可以解决您的问题。在我的情况下确实如此。

原文由 Nabil Mohammed Nalakath 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题