我有一个构建和运行的 TypeScript 项目,但我有一大堆构建错误,这些错误似乎都源于一个错误:
TS4090: (TS) Conflicting definitions for 'node' found at 'C:/[projectpath]/node_modules/@types/node/index.d.ts' and 'C:/[user path to Microsoft]/Typescript/3.1/node_modules/@types/node/index.d.ts'. Consider installing a specific version of this library to resolve the conflict.
我不明白“安装这个库的特定版本”。我不确定为什么一开始会发现两个版本。
我的应用程序在 ClientApp
文件夹中有一个 tsconfig.json
文件。它包含以下内容:
{
"compileOnSave": false,
"compilerOptions": {
"module": "esnext",
"skipLibCheck": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"target": "es2015",
"lib": [
"es2016",
"es2017",
"dom"
],
"moduleResolution": "node",
"allowJs": true,
"baseUrl": "src"
},
"include": [
"./src/**/*.ts",
"./test/**/*.ts",
"./custom_typings/**/*.d.ts"
],
"atom": {
"rewriteTsconfig": false
},
"typeAcquisition": {"enable": false}
}
我最近根据与此相关的其他帖子的评论添加了 typeAcquisition
-- 但它没有任何影响。
我需要做什么才能“安装该库的特定版本”?
环境
该项目以 .NetCore 2.2 为目标。该项目包含提供后端数据的 WebAPI Controller 以及包含使用 Aurelia 创建的 SPA UI 的 ClientApp 文件夹。我使用 WebPack 构建 SPA 应用程序。
错误
最佳答案
我通过移动解决了这个问题
"@types/node": "^10.11.6"
从 devDependencies
到我的 package.json
文件中的 peerDependencies
"peerDependencies": {
"@types/node": "^10.11.6"
},
关于typescript - 解决VS 2017中的 'Conflicting definitions for node' TS4090错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56690600/