首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Apollo-带有包裹警告的客户端

Apollo-带有包裹警告的客户端
EN

Stack Overflow用户
提问于 2018-10-23 20:48:45
回答 2查看 1.2K关注 0票数 13

我一直在尝试为我的react应用程序设置apollo-client。一切正常,但在控制台中,我的CI管道中的node_modules/apollo-client中有大量关于缺少源文件的警告。

我已尝试清除纱线缓存,删除node_modules并重新安装。但警告是持久的。我可能遗漏了一些关于parcel或babel配置的东西。找到的线索很少,但都是webpack特有的。

以下是日志:

代码语言:javascript
复制
⚠️  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"
EN

回答 2

Stack Overflow用户

发布于 2018-11-25 23:42:22

在为我的react应用程序设置apollo-client with parcel时,我遇到了同样的问题(并且没有使用typescript)。虽然我得到了相同的警告,但应用程序确实编译并正常工作。如果我理解正确的话,parcel正在尝试从node_modules解析源地图,但在apollo-client的情况下找不到它们。

抑制警告的一个简单解决方法是在项目根目录中添加一个简单的tsconfig.json文件:

./tsconfig.js

代码语言:javascript
复制
{
  "exclude": [
    "./node_modules",
    "**/*.spec.ts"
  ]
}
票数 4
EN

Stack Overflow用户

发布于 2019-08-11 22:07:22

这个问题的原因是parceljs试图从源映射中找到源文件。这些文件是否存在,您只需查看分布式文件夹即可查看。我不知道为何会显示警告。然而,并不是只有你一个人有这个问题(请参阅:https://github.com/parcel-bundler/parcel/issues/2185

要取消警告,您可以使用一个命令行界面选项:--log-level 1。但是请记住,您将禁止所有警告,这是我不推荐的!

如果任何人遇到错误:Property name expected type of string but got null,您可以使用以下选项来解决该问题:npx parcel watch ./server/src/YOUR_SOURCE_INDEX --out-dir ./YOUR_DESTINATION --no-hmr --target node

这也有一个问题:https://github.com/apollographql/apollo-server/issues/2453

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52949515

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档