Conflicting definitions for 'node'
Closed this issue · 2 comments
r4881t commented
I have a project with dependencies as
"devDependencies": {
"@types/bs58": "^4.0.1",
"@types/buffers": "^0.1.31",
"@types/chai": "^4.3.0",
"@types/express": "^4.17.13",
"@types/jest": "^27.4.1",
"@types/jsonwebtoken": "^8.5.8",
"@types/mocha": "^9.1.0",
"@types/nock": "^11.1.0",
"@types/sinon": "^10.0.11",
"@typescript-eslint/eslint-plugin": "^5.17.0",
"@typescript-eslint/parser": "^5.17.0",
"chai": "^4.3.6",
"chai-http": "^4.3.0",
"concurrently": "^7.0.0",
"eslint": "^8.12.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.5.1",
"mocha": "^9.2.2",
"nock": "^13.2.4",
"nodemon": "^2.0.15",
"prettier": "2.6.1",
"sinon": "^13.0.1",
"ts-node": "^10.7.0",
"typescript": "^4.6.3"
},
"dependencies": {
"@alch/alchemy-web3": "^1.4.4",
"@aws-sdk/client-s3": "^3.58.0",
"@bitpack-me/entitybit": "0.0.40",
"@ethereumjs/tx": "^3.5.2",
"@solana/buffer-layout": "^4.0.0",
"@solana/spl-token": "0.1.8",
"@solana/web3.js": "1.39.1",
"@types/cors": "^2.8.12",
"@types/debug": "^4.1.7",
"@types/valid-url": "^1.0.3",
"axios": "^0.27.2",
"base64url": "^3.0.1",
"borsh": "^0.7.0",
"class-validator": "^0.13.2",
"cloudinary": "^1.29.0",
"cors": "^2.8.5",
"crypto": "^1.0.1",
"dotenv": "^16.0.0",
"express": "^4.17.3",
"express-promise-router": "^4.1.1",
"express-validator": "^6.14.0",
"express-winston": "^4.2.0",
"form-data": "^4.0.0",
"fs": "^0.0.1-security",
"js-sha3": "^0.8.0",
"jsonwebtoken": "^8.5.1",
"razorpay": "^2.8.1",
"sturdy-websocket": "^0.2.1",
"twilio": "^3.76.0",
"typeorm": "0.3.1",
"url-join-ts": "^1.0.5",
"valid-url": "^1.0.9",
"web3": "^1.7.1",
"web3-utils": "^1.7.1",
"winston": "^3.6.0",
"ws": "^8.8.0"
},
"peerDependencies": {
"@types/node": "^18.0.0"
},
"optionalDependencies": {
"bufferutil": "^4.0.6",
"utf-8-validate": "^5.0.9"
}
Upon building the project with tsc --project ./
I get the following error.
node_modules/@alch/alchemy-web3/node_modules/@types/bn.js/index.d.ts:8:23 - error TS4090: Conflicting definitions for 'node' found at '/Users/p/workspace/Back/node_modules/@alch/alchemy-web3/node_modules/@types/node/index.d.ts' and '/Users/p/workspace/Back/node_modules/@types/node/index.d.ts'. Consider installing a specific version of this library to resolve the conflict.
The file is in the program because:
Type library referenced via 'node' from file '/Users/p/workspace/Back/node_modules/dotenv/lib/main.d.ts' with packageId '@types/node/index.d.ts@18.0.0'
Type library referenced via 'node' from file '/Users/p/workspace/Back/node_modules/@alch/alchemy-web3/node_modules/@types/bn.js/index.d.ts' with packageId '@types/node/index.d.ts@12.20.55'
8 /// <reference types="node"/>
~~~~
node_modules/dotenv/lib/main.d.ts:2:23
2 /// <reference types="node" />
~~~~
File is included via type library reference here.
Found 1 error in node_modules/@alch/alchemy-web3/node_modules/@types/bn.js/index.d.ts:8
I understand this may be out of scope for this repo, but any help is appreciated.
r4881t commented
I thought that this is due to dotenv
package; and I reorganised my repo into a monorepo to have different dependencies and all that jazz, but after that I am again facing this error. This time, my package.json
looks like below
"dependencies": {
"@alch/alchemy-web3": "^1.4.4",
"dotenv": "^16.0.1",
"sturdy-websocket": "^0.2.1",
"websocket": "^1.0.28"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.30.3",
"@typescript-eslint/parser": "^5.30.3",
"eslint": "^8.19.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"nodemon": "^2.0.18",
"prettier": "^2.7.1",
"ts-node": "^10.8.1",
"typescript": "^4.7.4"
}
And I am getting error for
error TS4090: Conflicting definitions for 'node' found at '/Users/p/workspace/Back/node_modules/@alch/alchemy-web3/node_modules/@types/node/index.d.ts' and '/Users/p/workspace/Back/node_modules/@types/node/index.d.ts'. Consider installing a specific version of this library to resolve the conflict.
The file is in the program because:
Type library referenced via 'node' from file '/Users/p/workspace/Back/node_modules/@types/ws/index.d.ts' with packageId '@types/node/index.d.ts@18.0.0'
Type library referenced via 'node' from file '/Users/p/workspace/Back/node_modules/@alch/alchemy-web3/node_modules/@types/bn.js/index.d.ts' with packageId '@types/node/index.d.ts@12.20.55'
r4881t commented
I am able to resolve the second error by adding following to my tsconfig.json
"typeRoots": [
"types",
"../../node_modules/@types" // Since this is a monorepo
]