无法读取 tsconfig.base.json! - 阿波罗 Angular 项目设置

Couldn't read tsconfig.base.json! - Apollo Angular project setup

ng add apollo-angular

它发出了一些警告:

UPDATE src/app/app.module.ts (541 bytes)
npm WARN notsup Unsupported engine for extract-files@9.0.0: wanted: {"node":"^10.17.0 || ^12.0.0 || >= 13.7.0"} (current: {"node":"10.16.3","npm":"6.12.0"})
npm WARN notsup Not compatible with your version of node/npm: extract-files@9.0.0
npm WARN karma-jasmine-html-reporter@1.5.4 requires a peer of jasmine-core@>=3.5 but none is installed. You must install peer dependencies yourself.
npm WARN @apollo/client@3.1.3 requires a peer of react@^16.8.0 but none is installed. You must install peer dependencies yourself.
npm WARN @apollo/client@3.1.3 requires a peer of subscriptions-transport-ws@^0.9.0 but none is installed. You must install peer dependencies yourself.

因此,在添加对等依赖项之后,我尝试再添加一次 apollo-angular:

MIA-LT-16354:src SSilwal$ ng add apollo-angular
Skipping installation: Package already installed
? Url to your GraphQL endpoint https://o5x5jzoo7z.sse.codesandbox.io/graphql'
Couldn't read tsconfig.base.json!

环境:

@apollo/client: 3.0.0 阿波罗-angular:2.0.3 graphql:15.3.0 @angular/core:9.1.7 @angular/cli:9.1.12 typescript:3.8.3

这个问题通常发生在您的Angular项目之前进行过版本迁移,导致tsconfig.base.json丢失或无效。

您可以尝试按照官方文档的指导手动安装apollo-angular

Apollo Angular official guide 关于在没有 Angular 原理图的情况下安装 apollo-angular

或按照我在下面提到的手册更新进行操作:


问题作者提出的 Github issue 提供了仅更新 angular 版本的修复方法,请先尝试此方法

在我遇到这个问题的时候,使用下面的命令帮助了一些人,但没有解决我的问题

免费试用

ng update @angular/cli --migrate-only --from 9 --to 10
ng update @angular/core --migrate-only --from 9 --to 10

如果遇到错误,请尝试使用 --force(谨慎使用!!)

这是解决因迁移 Angular 版本

而导致的 tsconfig.base.json 问题的解决方案

主要来源:Github issue related to this question

注意它有一些副作用

Angulars Official Docs 阅读更多关于如何根据项目的复杂程度正确迁移的信息


我个人使用这个命令安装了所有需要的包,并按照指南添加了需要的模块。

ng update apollo-angular --migrate-only --from 1.10.0

如果遇到错误,请尝试使用 --force(谨慎使用!!)

ng update apollo-angular --migrate-only --from 1.10.0 --force

我希望这有帮助:)

P.S在伊朗等部分国家可能需要代理才能使用 ng add apollo-angular