typescript - 解决VS 2017中的 'Conflicting definitions for node' TS4090错误

标签 typescript visual-studio-2017 aurelia

我有一个构建和运行的 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 应用程序。

错误

enter image description here

最佳答案

我通过移动解决了这个问题

"@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/

相关文章:

angular - 从 AngularJS 中的任何其他组件调用时更改模态调用按钮的文本

javascript - TypeScript:实现接口(interface)时是否需要参数类型?

visual-studio - VS 中可以用键盘/鼠标滚轮水平滚动吗?

sass - 在 Aurelia 的 Skeleton Navigation 项目中使用 SASS

dependency-injection - 实例化对象时的 Aurelia 依赖注入(inject)

javascript - this 变量是 Window 对象或在 Promise 的 then 方法中未定义

typescript - visual studio 2015 asp.net 5 aurelia, typescript 编译错误

Angular 7 : Service instance working incorrectly

c++ - 在 OpenGL 中对四边形进行纹理化

c++ - 如何使用位域结构和 union 生成 4 个字节?