我有一个打字稿存储库,无法在我的机器上构建错误...
$ 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.
当我翻阅node_modules
时,我找不到任何提及@types/graphql
.但是,我确实在打字稿模块中找到了AsyncIterator
...
当我在 ubuntu 的 docker 容器中运行构建时,它通过了正常,但是在我的本地 OSSierra 机器上,我收到此错误。我在网上找到了修复程序,说要在tsconfig.json
中的库中添加"esnext",这似乎确实有效,但这个回购不受我的控制,我仍然无法解释为什么会发生这种情况。有什么想法吗?
我们通过从父目录(在本例中为主目录)中删除流氓node_modules文件夹来解决它。
打字稿/节点的模块分辨率在父目录中查找更多信息"信息",也许其他人有更好的解释:)