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

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


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


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

"compilerOptions": {        ....         "typeRoots": [            "node_modules/@types"        ]        ....}


For me, it was karma.config file, which was causing the issues.

After I have deleted some of the types in the package.json, I managed to reduce the number of errors and there was only one - between signalr and karma.

Screenshot of error

For some reason I had a .js, not .ts karma config.
After I had switched to the correct configuration and restarted the VS, the problem was resolved.

It have needed some version of node as there was a require function used.
My theory is, Visual Studio automatically included types for accessible version of node, as a part of linting functionality for JavaScript.
But then, after it compiled typescript, another version of types for node was included - conflicting with the one already present.

None of the operations in tsconfig.json file would have resolved the issue, as the conflict was present between node types for TS and node types for JS.