2-1. Hardhat 설치

동동주·2025년 9월 21일

Hardhat
=framework (개발환경)

이게 뭐더라...

nvm use v20.11.0    //nodejs 세팅

npm init -y //세팅 스킵
{
  "name": "hardhat-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

- hardhat 설치

 npm install --save-dev hardhat 
 // 개발 환경에서 사용하는 패키지 = dev?
 // save = dependencies?

- 권한 오류? 해결(?)

/mnt/e/J/blockchain_programming_2025/hardhat-test ── 04:09:04 PM ─╮
❯ npm install --save-dev hardhat                                 ─╯
npm ERR! code EPERM
npm ERR! syscall chmod
npm ERR! path /mnt/e/JWorks/blockchain_programming_2025/hardhat-test/node_modules/esbuild/bin/esbuild
npm ERR! errno -1
npm ERR! Error: EPERM: operation not permitted, chmod '/mnt/e/JWorks/blockchain_programming_2025/hardhat-test/node_modules/esbuild/bin/esbuild'
npm ERR!  [Error: EPERM: operation not permitted, chmod '/mnt/e/JWorks/blockchain_programming_2025/hardhat-test/node_modules/esbuild/bin/esbuild'] {
npm ERR!   errno: -1,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'chmod',
npm ERR!   path: '/mnt/e/JWorks/blockchain_programming_2025/hardhat-test/node_modules/esbuild/bin/esbuild'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in: /home/jiyu/.npm/_logs/2025-09-21T07_09_11_161Z-debug-0.log
/mnt/e/JWorks/blockchain_programming_2025/hardhat-test ─────────────


//대충 권한이 없어서 안된다고 함


/mnt/e/J/blockc/hardhat-test ───────────── ✘ 255 57s 04:10:08 PM ─╮
❯ sudo umount /mnt/e                                             ─╯
[sudo] password for user: 
umount: /mnt/e: target is busy.

// "target is busy" 오류가 났습니다. 즉, /mnt/e 경로가 사용 중이어서 마운트를 해제하지 못한 상태입니다.
// 마운트를 해제하려면 /mnt/e를 참조하고 있는 프로세스나 터미널 등을 모두 종료하거나 해당 경로에서 작업 중인 프로세스를 찾아 종료해야 합니다.
// hardhat-test 파일을 열고 있어서 그런 것 같은데.. 왜 해결이 된건지 미지수

/mnt/e/J/blockchain_programming_2025/hardhat-test ── 04:12:54 PM ─╮
❯ sudo mount -t drvfs E: /mnt/e -o metadata,exec                 ─╯
/mnt/e/J/blockchain_programming_2025/hardhat-test ── 04:13:12 PM ─╮
❯ mount | grep /mnt/e                                            ─╯
E:\ on /mnt/e type 9p (rw,noatime,dirsync,aname=drvfs;path=E:\;uid=0;gid=0;symlinkroot=/mnt/,mmap,access=client,msize=65536,trans=fd,rfd=8,wfd=8)
E: on /mnt/e type 9p (rw,relatime,dirsync,aname=drvfs;path=E:;metadata;symlinkroot=/mnt/,mmap,access=client,msize=65536,trans=fd,rfd=3,wfd=3)
/mnt/e/J/blockchain_programming_2025/hardhat-test ── 04:13:28 PM ─╮
❯ npm install --save-dev hardhat                                 ─╯

added 57 packages, and audited 58 packages in 55s

14 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
/mnt/e/J/blockc/hardhat-test ─────────────────── 55s 04:14:31 PM ─╮
❯          

근데 뭔가 해보려던 게 무산되었는데
왜 설치가 제대로 실행 된건지 모르겠음

- 설치 성공 시

// package.json 파일에 해당 코드가 추가됨

  "devDependencies": {
    "hardhat": "^3.0.6"
   

Hardhat v2 설치..(변경)

  • 수업에서 hardhat v2를 이용한다며 해당 코드를 줌.
    (v3와 큰 차이는없으나 처음 hardhat을 사용하는 학생 입장에서는 여러 오류가 발생할 수 있으니 꼭 버전을 동일시해서 수업을 진행하시는 것을 권장드립니다.)라고 함
nvm use v20.19.4

npm install hardhat@2.22.19

npx hardhat init

이거 차례대로 입력하니까

// package.json 파일에 해당 코드가 추가됨

"@nomicfoundation/hardhat-toolbox-viem": "^3.0.0", //
"hardhat": ~~
"ts-node": "^10.9.2"

이렇게 나옴..

- typescript 설치라는데 안해도 될 듯

(결과물이 동일하게 나온듯함)

npm install --save-dev ts-node 

로그 기록 (Hardhat 설치과정)

/mnt/e/J/blockchain_programming_2025/hardhat-test ── 04:13:28 PM ─╮
❯ npm install --save-dev hardhat                                 ─╯

added 57 packages, and audited 58 packages in 55s

14 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

// 설치 성공 시점

/mnt/e/J/blockc/hardhat-test ─────────────────── 55s 04:14:31 PM ─╮
❯ npm install --save-dev ts-node                                 ─╯

added 20 packages, and audited 78 packages in 11s

14 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
// 타입스크립티 설치를 했는데

/mnt/e/J/blockc/hardhat-test ─────────────────── 12s 04:20:40 PM ─╮
❯ nvm use v20.19.4                                               ─╯
N/A: version "v20.19.4" is not yet installed.

You need to run `nvm install v20.19.4` to install and use it.
// 버전 관련... 이슈로 다시 

/mnt/e/J/blockchain_programming_2025/hardhat-test ── 04:21:20 PM ─╮
❯ nvm install v20.19.4                                           ─╯
Downloading and installing node v20.19.4...
Downloading https://nodejs.org/dist/v20.19.4/node-v20.19.4-linux-x64.tar.xz...
############################################################# 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v20.19.4 (npm v10.8.2)
// 없어서 설치했고요

/mnt/e/J/blockc/hardhat-test ────── 11s Node 20.19.4 04:21:58 PM ─╮
❯ nvm use v20.19.4                                               ─╯
Now using node v20.19.4 (npm v10.8.2)



/mnt/e/J/blockc/hardhat-test ────────── Node 20.19.4 04:22:01 PM ─╮
❯ npm install hardhat@2.22.19                                    ─╯
npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated glob@8.1.0: Glob versions prior to v9 are no longer supported
npm warn deprecated ethereumjs-abi@0.6.8: This library has been deprecated and usage is discouraged.

added 238 packages, removed 20 packages, changed 19 packages, and audited 296 packages in 2m

70 packages are looking for funding
  run `npm fund` for details

5 low severity vulnerabilities

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.


/mnt/e/J/blockc/hardhat-test ─── 1m 58s Node 20.19.4 04:24:10 PM ─╮
❯ npx hardhat init                                               ─╯
888    888                      888 888               888
888    888                      888 888               888
888    888                      888 888               888
8888888888  8888b.  888d888 .d88888 88888b.   8888b.  888888
888    888     "88b 888P"  d88" 888 888 "88b     "88b 888
888    888 .d888888 888    888  888 888  888 .d888888 888
888    888 888  888 888    Y88b 888 888  888 888  888 Y88b.
888    888 "Y888888 888     "Y88888 888  888 "Y888888  "Y888

Welcome to Hardhat v2.22.19

// 선택창이 떠요!!!!
✔ What do you want to do? · Create a TypeScript project (with Viem) 
// 타입스크립트라고 해서 타입스크립트 했고요 
// + viem 이 vim인줄 알고 요걸로 설치함 (바보)
✔ Hardhat project root: · /mnt/e/JWorks/blockchain_programming_2025/hardhat-test

✔ Do you want to add a .gitignore? (Y/n) · y
✔ Do you want to install this sample project's dependencies with npm (@nomicfoundation/hardhat-toolbox-viem)? (Y/n) · y
// 다른 것들은.. 일단 넘치는 게 차라리 낫지 않을까 해서 설치했습니다

npm install --save-dev "@nomicfoundation/hardhat-toolbox-viem@^3.0.0"
npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
npm warn deprecated glob@5.0.15: Glob versions prior to v9 are no longer supported
npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported

added 280 packages, removed 15 packages, changed 10 packages, and audited 561 packages in 5m

120 packages are looking for funding
  run `npm fund` for details

13 low severity vulnerabilities

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

Project created

See the README.md file for some example tasks you can run

Give Hardhat a star on Github if you're enjoying it!

     https://github.com/NomicFoundation/hardhat
 
profile
배운 내용 정리&기록, 스크랩

0개의 댓글