Closed sebastiantf closed 2 years ago
This may be related to https://github.com/dethcrypto/TypeChain/discussions/526.
What version of hardhat
, typechain
and @typechain/ethers-v5
did you use?
Updated the op with the related dependencies
Yeah this is caused by https://github.com/dethcrypto/TypeChain/discussions/526.
Make sure to follow the peer dependency rules listed in my package.json file. You can't use hardhat-packager
with the latest versions of TypeChain (yet). I'm working on a fix as we speak.
Okay, this should be fixed in v1.3.0.
Let me know if that works for you, @sebastiantf!
Awesome! Working fine now! Thanks!
@PaulRBerg I am experiencing the same issue in my repository when upgrading to the latest version of Hardhat 2.20.0 and ethers v6. This is my package.json
below:
This is the PR and the file changes where we are experiencing the issue: https://github.com/lukso-network/lsp-smart-contracts/pull/889/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519
"devDependencies": {
"@b00ste/hardhat-dodoc": "^0.3.16",
"@erc725/erc725.js": "0.23.0",
"@lukso/eip191-signer.js": "^0.2.2",
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
"@nomiclabs/hardhat-web3": "^2.0.0",
"@turbo/gen": "^1.12.3",
"@typechain/ethers-v6": "^0.5.1",
"@typechain/hardhat": "^9.1.0",
"all-contributors-cli": "^6.26.1",
"dotenv": "^16.0.3",
"esbuild": "^0.17.15",
"eslint": "^7.32.0",
"eslint-config-custom": "*",
"eth-create2-calculator": "^1.1.5",
"ethers": "^6.11.0",
"hardhat": "^2.20.0",
"hardhat-contract-sizer": "^2.8.0",
"hardhat-deploy": "^0.11.25",
"hardhat-deploy-ethers": "^0.4.1",
"hardhat-gas-reporter": "^1.0.9",
"hardhat-packager": "^1.4.2",
"markdown-table-ts": "^1.0.3",
"npm-run-all": "^4.1.5",
"pluralize": "^8.0.0",
"prettier": "^2.8.8",
"prettier-plugin-solidity": "^1.1.3",
"rollup-plugin-esbuild": "^5.0.0",
"solhint": "^3.6.2",
"ts-node": "^10.2.0",
"turbo": "latest",
"typechain": "^8.3.2",
"typescript": "^5.3.3",
"unbuild": "^2.0.0",
"vite-plugin-checker": "^0.5.6",
"vite-tsconfig-paths": "^4.0.7",
"web3": "^1.5.2"
},
"peerDependencies": {
"@typechain/hardhat": "9.x",
"hardhat": "2.x",
"lodash": "4.x",
"typechain": "8.x"
},
The reason it was failing is because hardhat-packager
uses v6.0.0 of @typechain/hardhat
, while my package.json
had ^9.1.0
set.
In order to solve this, we had to do the following:
package.json
, to force resolution to only this version."resolutions": {
"@typechain/hardhat": "9.1.0"
}
preinstall
command in the "script": {}
section of the package.json
:"scripts": {
"preinstall": "npx --yes force-resolutions",
// your other scripts...
}
delete your node_modules (and package-lock.json
as well eventually). And re-run npm i
re-run npm i
a 2nd time after the new package-lock.json
got generated.
After that, you can run the following rg
command below to ensure only one dependency of @typechain/hardhat
is installed to resolve to. If two version appear (the one as well from hardhat-packager
, then it will not work.
rg --no-ignore -l noTypechain node_modules
Kudos to @richtera for his help on debugging this issue! 🚀
npx hardhat
-->Create an advanced sample project that uses TypeScript
yarn add --dev hardhat-packager typechain @typechain/hardhat @typechain/ethers-v5
Running any hardhat task fails with the following error:
Searching for
noTypechain
yields the following results:@typechain/hardhat
frompackage.json
and reinstalledLooks like some kind of conflict for the
@typechain/hardhat
packageRelated dependencies used: