【发布时间】:2019-08-11 02:23:34
【问题描述】:
我在尝试构建我的项目(使用 Angular CLI)时收到以下错误
ERROR in ../my-app/node_modules/@types/jasmine/index.d.ts(18,1): error TS6200: Definitions of the following identifiers conflict with those in another file: Expected, SpyObjMethodNames, clock, CustomEqualityTester, CustomMatcherFactory, ExpectationFailed, SpecFunction, SpyObj, jasmine
我正在使用 VSCode,当我转到有问题的行时,我可以选择查看它说它与之冲突的文件。
这会将我带到以下位置的文件:
/Users/<user_name>/Library/Caches/typescript/3.3/node_modules/@types/jasmine/ts3.1/index.d.ts
我有点不明白为什么 TS 编译器会尝试使用这个缓存的类型定义,这里会发生什么?
谢谢
【问题讨论】:
-
您是否尝试过删除 node_modules 和 package-lock.json,清除 npm 缓存(npm cache clean --force)并重新安装依赖项?
-
请您分享您的打字稿版本
-
感谢@TheParam - 我尝试了您建议的步骤,但仍然遇到相同的错误。我刚刚检查了 Angular CLI 在构建时使用的 TypeScript 版本及其在 3.2.4 上的版本,我看到我上面共享的缓存路径引用了 TS 的 3.3 版本,所以也许这就是问题所在,缓存副本与项目中 node_modules 文件夹中的副本之间的版本差异?
-
是的,这可能是问题所在。您可以删除缓存的文件夹并重新安装打字稿会有所帮助
-
你解决了吗?我也有类似的问题。
标签: angular typescript jasmine