一直在尝试为我的react应用程序使用宗地设置apollo客户端。一切正常,但是在控制台中,关于我的CI管道中的node_modules / apollo-client中缺少源文件的警告很多。
尝试清除纱线缓存,删除node_modules并重新安装。但是警告是持久的。我可能缺少包裹或Babel配置的东西。没有发现任何提示,但它们是针对webpack的。
以下是日志:
⚠️ Could not load source file "../../src/data/store.ts" in source map of "../node_modules/apollo-client/data/store.js".
⚠️ Could not load source file "../../src/util/Observable.ts" in source map of "../node_modules/apollo-client/util/Observable.js"
.
⚠️ Could not load source file "../../src/core/QueryManager.ts" in source map of "../node_modules/apollo-client/core/QueryManager.js".
⚠️ Could not load source file "../../src/data/mutations.ts" in source map of "../node_modules/apollo-client/data/mutations.js".
⚠️ Could not load source file "../../src/scheduler/scheduler.ts" in source map of "../node_modules/apollo-client/scheduler/scheduler.js".
⚠️ Could not load source file "../../src/data/queries.ts" in source map of "../node_modules/apollo-client/data/queries.js".
⚠️ Could not load source file "../../src/errors/ApolloError.ts" in source map of "../node_modules/apollo-client/errors/ApolloError.js".
⚠️ Could not load source file "../../src/core/networkStatus.ts" in source map of "../node_modules/apollo-client/core/networkStatus.js".
⚠️ Could not load source file "../src/ApolloClient.ts" in source map of "../node_modules/apollo-client/ApolloClient.js".
⚠️ Could not load source file "../../src/core/ObservableQuery.ts" in source map of "../node_modules/apollo-client/core/ObservableQuery.js".
⚠️ Could not load source file "../src/index.ts" in source map of "../node_modules/apollo-client/index.js".
⚠️ Could not load source file "../../src/core/types.ts" in source map of "../node_modules/apollo-client/core/types.js"
答案 0 :(得分:0)
在为我的react应用设置带宗地的apollo客户端时,我遇到了同样的问题(并且没有使用打字稿)。当我收到相同的警告时,该应用程序会编译并正常运行。如果我正确理解了这种情况,则包裹将尝试从node_modules解析源地图,但在apollo-client的情况下找不到正确的源地图。
抑制警告的简单方法是在项目根目录中添加一个简单的tsconfig.json文件:
./ tsconfig.js
{
"exclude": [
"./node_modules",
"**/*.spec.ts"
]
}
答案 1 :(得分:0)
此问题的原因是parceljs尝试从源映射中查找源文件。这些文件已存在,您可以通过简单地查看分布式文件夹来检查。我不知道为什么会显示警告。但是,您并不孤单,请参见:https://github.com/parcel-bundler/parcel/issues/2185
要取消显示警告,可以使用CLI选项:def
ghi
。但是请记住,您将禁止所有警告,我不建议这样做!
如果有人遇到错误:--log-level 1
,则可以使用以下选项解决该问题:Property name expected type of string but got null
还有一个问题:https://github.com/apollographql/apollo-server/issues/2453