File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,75 @@ timezone: UTC+8
1515## Notes
1616
1717<!-- Content_START -->
18+ # 2025-08-18
19+
20+ ### 1️⃣ npm 下载的内容的是什么?
21+
22+ - ` npm ` 本身是 ** Node.js 的包管理工具** (Node Package Manager)。
23+ - 当你运行 ` npm install ` 的时候,它会根据项目中的 ** ` package.json ` ** 文件下载依赖(dependencies 和 devDependencies)。
24+ - 下载的内容就是各种库(比如 ` react ` , ` ethers ` , ` hardhat ` 等),然后放到本地项目的 ** ` node_modules/ ` 文件夹** 里。
25+ - 简单说:` package.json ` 就像“菜单”,` npm ` 根据它去下载对应的“菜”(库)。
26+
27+ ### ** 2️⃣ npm 和 npx 的区别**
28+
29+ - ** npm** 用来 ** 安装包** :
30+
31+ ``` bash
32+ npm install hardhat
33+
34+ ```
35+
36+ 会把 hardhat 装到项目里。
37+
38+ - ** npx** 用来 ** 直接运行包** (不需要全局安装):
39+
40+ ` ` ` bash
41+ npx hardhat
42+
43+ ` ` `
44+
45+ 会去项目里的 ` node_modules/.bin` 找到 ` hardhat` 并执行。
46+
47+ 👉 所以 ` npx` 适合执行 CLI 工具,不需要全局安装,避免版本冲突。
48+
49+
50+ > 🌰 举例:
51+ >
52+ > - ` npm install create-react-app -g` 再 ` create-react-app myapp` (传统方式)
53+ > - 直接 ` npx create-react-app myapp` (推荐方式)
54+
55+ ---
56+
57+ # ## **3️⃣ Hardhat 是什么?**
58+
59+ - ** Hardhat** 是一个 ** 以太坊开发框架** ,主要用于智能合约开发、测试和部署。
60+ - 功能包括:
61+ - 合约编译(用 ` solc` 编译器)
62+ - 本地测试链(` npx hardhat node` )
63+ - 部署合约(脚本 + ethers.js)
64+ - 编写单元测试(Mocha + Chai)
65+ - 对标的工具是 ** Truffle** ,但 Hardhat 更现代,更适配 TypeScript/ethers.js。
66+
67+ ---
68+
69+ # ## **4️⃣ 合约在 VSCode 中是怎么编译的?**
70+
71+ - 在 VSCode 里你一般是通过 Hardhat 或 Truffle 来编译,而不是手动点按钮。
72+ - 常见方式:
73+
74+ ` ` ` bash
75+ npx hardhat compile
76+
77+ ` ` `
78+
79+ 这会调用 Solidity 编译器(solc),生成 ` artifacts/` 文件夹,里面有 ABI 和字节码。
80+
81+ - ** 除了 Remix 编译器,其他选择:**
82+ 1. ** Hardhat** ✅(最主流,功能全)
83+ 2. ** Truffle** (老牌框架,功能类似 Hardhat)
84+ 3. ** Foundry** 🚀(新兴的超快编译/测试框架,用 Rust 写的,速度快)
85+ 4. ** Brownie** (Python 社区常用,基于 web3.py)
86+
1887# 2025-08-16
1988
2089# # 运营
You can’t perform that action at this time.
0 commit comments