为什么 Angular 会从我的 node_modules 文件夹中报告错误?

时间:2021-05-19 14:22:13

标签: angular npm

运行 ng serve 时,它成功开始服务,但随后列出了一堆错误,例如:

chunk {main} main.js, main.js.map (main) 2.02 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 689 bytes [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.15 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 1.89 MB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 341 kB [initial] [rendered]
Date: 2021-05-19T14:16:23.633Z - Hash: a3c27b44ab59c4ca8e77 - Time: 22993ms

ERROR in node_modules/rxjs/src/internal/Subscription.ts:33:13 - error TS2322: Type 'null' is not assignable to type 'Subscription | Subscription[]'.

33   protected _parentOrParents: Subscription | Subscription[] = null;

... more errors ...


** Angular Live Development Server is listening on localhost:4222, open your browser on http://localhost:4222/ **

在浏览器中打开该 URL 时,我得到 Cannot GET / 的单个输出。

我曾尝试删除 node_modules 并再次运行 npm install,但这没有帮助。

1 个答案:

答案 0 :(得分:0)

错误就是线索。我试图解决 rxjs 中的 empty() 被弃用的问题,并错误地使用了他们的建议,即使用 EMPTY 常量和不带参数的 of() 方法。

我用 new Observable<>() 替换了它,它构建得很好。