无法读取tsconfig.base.json! -Apollo Angular项目设置

问题描述

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-angleular:

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 /客户:3.0.0 圆角:2.0.3 graphql:15.3.0 @角/核心:9.1.7 @角度/ cli:9.1.12 打字稿: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