node.js - typescript repo build 在我的机器上失败,但在 ubuntu docker 中通过
问题描述
我有一个 typescript repo 无法在我的机器上构建并出现错误...
$ tsc --pretty -p tsconfig.json
../../../../../../node_modules/@types/graphql/subscription/subscribe.d.ts:17:12 - error TS2304: Cannot find name 'AsyncIterator'.
17 ): Promise<AsyncIterator<ExecutionResult> | ExecutionResult>;
~~~~~~~~~~~~~
../../../../../../node_modules/@types/graphql/subscription/subscribe.d.ts:29:12 - error TS2304: Cannot find name 'AsyncIterable'.
29 ): Promise<AsyncIterable<any>>;
~~~~~~~~~~~~~
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@types/graphql
当我通过 grep 时,我找不到任何提及node_modules
。我确实AsyncIterator
在打字稿模块中找到了......
当我在 ubuntu 的 docker 容器中运行构建时,它通过了,但是在我的本地 OSSierra 机器上我收到了这个错误。我在网上找到了修复程序,说要在 中的库中添加“esnext” tsconfig.json
,这似乎确实有效,但是这个 repo 不在我的控制之下,我仍然无法解释为什么会发生这种情况。有任何想法吗?
解决方案
我们通过从父目录(在我们的例子中是主目录)中删除一个流氓 node_modules 文件夹来解决它。
显然打字稿/节点的模块解析在父目录中查找更多“信息”,也许其他人有更好的解释:)
推荐阅读
- javascript - 当用户点击左侧详细信息中的产品时如何创建将显示在右侧
- servicestack - ServiceStack:“Matching = ...”规则的解释
- c# - 我怎样才能有一个什么都不做的 LINQ where 子句?
- css - 为什么顺风 css 类名中有反斜杠?
- json - 匹配两个Json响应时忽略一个键
- tex - 如何在多行闭括号内居中数学表达式?
- django-rest-framework - Django Rest Framework 文档嵌套序列化程序
- batch-file - 在for循环中获取目录的最后一部分,使用cd,并在一行中
- c++ - DLL 导出类:抽象基类和 pimpl?
- amazon-web-services - AWS:有没有办法暂停/取消暂停 Elastic LoadBalancers 的流量?