打字稿:如何解决 'rxjs/Rx 没有导出的成员 'SubscriptionLike' [英] Typescript : How to resolve 'rxjs/Rx has no exported member 'SubscriptionLike'
问题描述
我正在尝试在此处遵循此示例 https://www.youtube.com/watch?v=gxCu5TEmxXE,但是在执行 tsc -p
时,出现错误.有什么需要导入的吗?
I'm trying to follow this example here https://www.youtube.com/watch?v=gxCu5TEmxXE, but when doing tsc -p
, I get an error. Is there something I need to import?
错误:
node_modules/@angular/common/src/location/location.d.ts(1,10): error TS2305: Module '"...functions/node_modules/rxjs/Rx"' has no export member'SubscriptionLike'.
TS 文件
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"
]
}
推荐答案
关注后遇到同样的问题
经过大量搜索,我发现Angular 6不支持通过本教程中的说明安装的Rxjs包.
After searching a lot, I have found that Rxjs package that is installed through instructions in this tutorial is not supported with Angular 6.
Angular 6 不适用于 RxJS 5.5,但适用于 RxJS 6.
Angular 6 does not work with RxJS 5.5 but with RxJS 6.
npm i rxjs@6
在 cli 中运行上述命令应该可以解决您的问题.在我的情况下确实如此.
Run the above command in cli and that should fix your problem. It did in my case.
这篇关于打字稿:如何解决 'rxjs/Rx 没有导出的成员 'SubscriptionLike'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!