smartcontractkit / full-blockchain-solidity-course-js

Learn Blockchain, Solidity, and Full Stack Web3 Development with Javascript
12.56k stars 3k forks source link

Cant install dependencies after setting up hardhat #631

Closed Maakai123 closed 2 years ago

Maakai123 commented 2 years ago

I cant install dependencies after setting up hardhat, i was not given options to install am them automatically, i ran into the below errors when installing them manually using this command npm install --save-dev @nomiclabs/hardhat-waffle 'ethereum-waffle@^3.0.0' @nomiclabs/hardhat-ethers,

info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. PS C:\Users\PC\Desktop\DEVELOPEMENT\HARDHATDEMO> npm install --save-dev @nomiclabs/hardhat-waffle 'ethereum-waffle@^3.0.0' @nomiclabs/hardhat-ethers 'ethers@^5.0.0' npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: HARDHATDEMO@1.0.0
npm ERR! Found: ethereum-waffle@3.0.0 npm ERR! node_modules/ethereum-waffle npm ERR! dev ethereum-waffle@"3.0.0" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer ethereum-waffle@"^3.2.0" from @nomiclabs/hardhat-waffle@2.0.3 npm ERR! node_modules/@nomiclabs/hardhat-waffle npm ERR! dev @nomiclabs/hardhat-waffle@"*" from the root project npm ERR! npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this command with --force, or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution. npm ERR! npm ERR! See C:\Users\PC\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\PC\AppData\Local\npm-cache_logs\2022-06-28T19_22_08_016Z-debug-0.log PS C:\Users\PC\Desktop\DEVELOPEMENT\HARDHATDEMO>

ximon-x commented 2 years ago

Try running the installation command with the --force flag:

npm install --save-dev --force @nomiclabs/hardhat-waffle 'ethereum-waffle@^3.0.0' @nomiclabs/hardhat-ethers 'ethers@^5.0.0'
Maakai123 commented 2 years ago

Thank you so much it worked perfectly, thank you so much

ximon-x commented 2 years ago

Alright. 😁

Maakai123 commented 2 years ago

i had another issues when install prettier with, yarn add--dev prettier prettier -plugin-solidity

i got this Error Message error An unexpected error occurred: "EPERM: operation not permitted, unlink 'C:

ximon-x commented 2 years ago

Try stopping the server before making the installation.

Maakai123 commented 2 years ago

how should i do that?

Maakai123 commented 2 years ago

am a newbie, please how do i stop it?

ximon-x commented 2 years ago

Ctrl + c

Maakai123 commented 2 years ago

0k thank you, should i run Ctrl+c inside the vscode? or outside?

Avelous commented 2 years ago

I experienced these kind of issues before when installing dependencies so i alway clear cache and it works for me

npm cache clean --force

alymurtazamemon commented 2 years ago

@Maakai123 Please make to ask questions related to your problem in the discussions tab, and only create an issue if it is related to the course. Thanks have a nice day!

close #631

snake-py commented 2 years ago

Is there no better way than forcing the dependencies? @Salvien-code ?

ximon-x commented 2 years ago

@snake-py, there's probably going to be a better alternative but I don't know it since I don't know the root cause.

I'm on Linux so I can't reproduce the bug which might be a windows issue.

Hence, it's best to just use the --force flag until someone else provides a better alternative.

snake-py commented 2 years ago

@Salvien-code I am on Ubuntu 20 and I am seeing the same dependency conflict. When did you try out the installation the last time? Maybe some dependency got updated and they forgot to increase the version on a co-dependency?

ximon-x commented 2 years ago

@Salvien-code I am on Ubuntu 20 and I am seeing the same dependency conflict. When did you try out the installation the last time? Maybe some dependency got updated and they forgot to increase the version on a co-dependency?

I installed them months back, but I couldn't reproduce the bug back then.

Can you please send the command you ran and also the log of your error message?

snake-py commented 2 years ago

command:

npm i -D @nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers ethers @nomiclabs/hardhat-etherscan @nomiclabs/hardhat-waffle chai ethereum-waffle hardhat hardhat-contract-sizer hardhat-deploy hardhat-gas-reporter prettier prettier-plugin-solidity solhint solidity-coverage dotenv

Output:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: hardhat-smartcontract-lottery-fcc@1.0.0
npm ERR! Found: @nomiclabs/hardhat-ethers@0.3.0-beta.13
npm ERR! node_modules/@nomiclabs/hardhat-ethers
npm ERR!   dev @nomiclabs/hardhat-ethers@"npm:hardhat-deploy-ethers" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! dev @nomiclabs/hardhat-waffle@"*" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: @nomiclabs/hardhat-ethers@2.2.1
npm ERR! node_modules/@nomiclabs/hardhat-ethers
npm ERR!   peer @nomiclabs/hardhat-ethers@"^2.0.0" from @nomiclabs/hardhat-waffle@2.0.3
npm ERR!   node_modules/@nomiclabs/hardhat-waffle
npm ERR!     dev @nomiclabs/hardhat-waffle@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /home/fabio/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/fabio/.npm/_logs/2022-11-01T16_50_21_856Z-debug-0.log
snake-py commented 2 years ago

I am running Node 16.16.0 and npm 8.19.2 via nvm

ximon-x commented 2 years ago

@snake-py It's quite odd but I got similar error message when I ran the command, but it worked when I used yarn:

yarn add -D @nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers ethers @nomiclabs/hardhat-etherscan @nomiclabs/hardhat-waffle chai ethereum-waffle hardhat hardhat-contract-sizer hardhat-deploy hardhat-gas-reporter prettier prettier-plugin-solidity solhint solidity-coverage dotenv 

Although there were a ton of warnings from yarn, the installation was successful. This also explains why I didn't encounter the error in the past. I've always used yarn for installing node modules and rarely ever use npm.

So this is most likely an npm issue.