我正在使用 gatsby、typescript 和 apollo(用于 graphql 查询)创建一个新的 React 应用程序。
在 dev 中进行测试时,应用程序编译并运行时不会抛出任何错误。
当我使用“gatsby build”转换构建时,它失败并出现错误。
我不明白为什么或在哪里触发。这似乎与 webpack 在构建时检查的方式有关,但我不知道如何查明问题,而且似乎没有任何材料可以为我提供明确的答案。
这似乎是由 httplink 模块引起的。出现在任何 .tsx 文件中时触发错误的代码是:
import { HttpLink } from 'apollo-link-http'
const link = new HttpLink({
uri: 'http://localhost:3001/graphql'
})
Run Code Online (Sandbox Code Playgroud)
显示的错误如下:
error Building static HTML failed
See our docs page on debugging HTML builds for help https://gatsby.dev/debug-html
10 | function InvariantError(message) {
11 | if (message === void 0) { message = genericMessage; }
> 12 | var _this = _super.call(this, typeof message === "number" …Run Code Online (Sandbox Code Playgroud)