【发布时间】:2018-08-02 21:30:35
【问题描述】:
据我了解,tutorial pnpm 在node_modules 下创建符号链接的.registry.npmjs.org 和其他条目点。我的项目在typescript 上,我有@types 用于输入node_modules。但是这个@types也有node_modules/.registry.npmjs.org/@types。所以我收到一个错误,例如:
/node_modules/.registry.npmjs.org/@types/jquery/3.3.5/node_modules/@types/jquery/index.d.ts(32,14): error TS2300: Duplicate identifier 'jQuery'.
...和
/node_modules/@types/jquery/index.d.ts(28,14): error TS2300: Duplicate identifier 'jQuery'.
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"lib": [
"es5",
"dom",
"es2015.promise"
],
"experimentalDecorators": true,
"sourceMap": true,
"allowSyntheticDefaultImports": true
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"scripts",
"src/contracts"
]
}
有什么解决办法吗?
【问题讨论】:
-
您是否已经在您的
tsconfig.json文件中设置了"exclude": ["node_modules/.registry.npmjs.org"]?这是我会尝试的第一件事,但我不会将其作为答案发布,因为我不太相信它会起作用。 -
@MattMcCutchen 是的,我试过了,但没有帮助......我也试过
"typeRoots": [ "./node_modules/@types"] -
我无法重现该问题。
tsc --traceResolution可能会有所帮助。如果您无法从输出中发现问题,请将其发布在问题中,我会查看。 -
@AlexFilatov 你使用什么版本的打字稿?我知道 v1 存在符号链接问题,但 v2/3 工作正常。实际上 pnpm 是用 typescript 编写的,而 typescript 2 没有这些问题
-
pnpm 也使用
@types,参见package.json。
标签: typescript types symlink typechecking pnpm