解决 VS 2017 中的“节点定义冲突"TS4090 错误 [英] Resolve 'Conflicting definitions for node' TS4090 error in VS 2017
问题描述
我有一个可以构建和运行的 TypeScript 项目,但我有大量构建错误,似乎都源于一个错误:
I have a TypeScript project that builds and runs, but I have a ton of build errors that all seem to stem from one error:
TS4090:(TS) 在 'C:/[projectpath]/node_modules/@types/node/index.d.ts' 和 'C:/[user path to Microsoft]/Typescript 中找到的 'node' 的定义冲突/3.1/node_modules/@types/node/index.d.ts'.考虑安装此库的特定版本以解决冲突.
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.
我不明白安装此库的特定版本".我不确定为什么会找到两个版本.
I don't understand the bit about "installing a specific version of this library". I'm not certain why two versions are being found to begin with.
我的应用程序在 ClientApp
文件夹中有一个 tsconfig.json
文件.它包含以下内容:
My app has a tsconfig.json
file located in the ClientApp
folder. It contains the following:
{
"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
- 但它没有影响.
I added the typeAcquisition
recently based on comments on other posts relating to this -- but it had no affect.
我需要做什么才能安装此库的特定版本"?
What do I need to do to "install a specific version of this library"?
环境
该项目面向 .NetCore 2.2.该项目包含提供后端数据的 WebAPI 控制器以及包含使用 Aurelia 创建的 SPA UI 的 ClientApp 文件夹.我使用 WebPack 构建 SPA 应用程序.
The project targets .NetCore 2.2. The project contains WebAPI Controllers that serve up backend data as well as a ClientApp folder that contains a SPA UI created with Aurelia. I use WebPack to build the SPA application.
错误
推荐答案
我通过移动解决了这个问题
I fixed this by moving
"@types/node": "^10.11.6"
从devDependencies
到我的package.json
文件中的peerDependencies
"peerDependencies": {
"@types/node": "^10.11.6"
},
这篇关于解决 VS 2017 中的“节点定义冲突"TS4090 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!