Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resolve 'Conflicting definitions for node' TS4090 error in VS 2017

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) 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.

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}
}

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"?

Environment

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.

Errors

enter image description here

like image 383
RHarris Avatar asked Jun 20 '19 16:06

RHarris


2 Answers

I fixed this by moving

"@types/node": "^10.11.6"

from devDependencies to the peerDependencies in my package.json file

"peerDependencies": {
    "@types/node": "^10.11.6"
  },
like image 140
4imble Avatar answered Nov 09 '22 05:11

4imble


For me, I fixed it by change/add "typeRoots" in compilerOptions (tsconfig.json)

"compilerOptions": {
        ....
         "typeRoots": [
            "node_modules/@types"
        ]
        ....
}
like image 44
Mahrez BenHamad Avatar answered Nov 09 '22 04:11

Mahrez BenHamad