# 1. 环境搭建 **Published by:** [Light](https://paragraph.com/@light-2/) **Published on:** 2021-12-19 **URL:** https://paragraph.com/@light-2/1 ## Content 大多数以太坊库和工具都是用JavaScript编写的,Hardhat也是如此。 如果你不熟悉Node.js,它是基于Chrome的V8 JavaScript引擎构建的JavaScript运行时。 这是在网络浏览器之外运行JavaScript的最受欢迎的解决方案,**Hardhat **就是建立Node.js之上。安装 Node.js 如果你已经安装了的 Node.js > = 12.0,则可以跳到下一节 如果没有,请按照以下步骤在Ubuntu,MacOS和Windows上安装它。LinuxUbuntu 将以下命令复制并粘贴到终端中: sudo apt update sudo apt install curl git curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - sudo apt install nodejsMacOS 确保你已安装git。 否则,请遵循这些说明 安装。 在MacOS上有多种安装Node.js的方法。 我们将使用 Node 版本管理器(nvm) 。 将以下命令复制并粘贴到终端中: curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.35.2/install.sh | bash nvm install 12 nvm use 12 nvm alias default 12 npm install npm --global # Upgrade npm to the latest versionWindows 在Windows上安装Node.js需要一些手动步骤。 我们将安装git,Node.js 12.x和NPM的Windows构建工具。 下载并运行以下命令:node-v12.XX.XX-x64.msi 在这里升级 Node.js 如果你的 Node.js 版本低于 12.0 , 则需要通过以下指引升级。LinuxUbuntu运行 sudo apt remove nodejs 删除 Node.js. 在这里 找到你想要安装的版本 运行 sudo apt update && sudo apt install nodejs 再次安装 MacOS 你可以使用 nvm 切换版本. 为了升级到 Node.js 12.x 可运行一下命令: nvm install 12 nvm use 12 nvm alias default 12 npm install npm --global # 升级 npm 到最新版本Windows 参考安装时同样的方式,但选择不同的版本,这里 列出了所有版本。 ## Publication Information - [Light](https://paragraph.com/@light-2/): Publication homepage - [All Posts](https://paragraph.com/@light-2/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@light-2): Subscribe to updates