Starting from this section, all commands need to be executed in the terminal program. If you want to learn the basic usage of the terminal, please move on Here

Because different readers use different operating systems and users who log in to the operating system, the installation preparation and installation steps may be slightly different. Here are two options based on whether the user (that is, you) logged in to the system is an administrator (root). The installation steps are roughly the same:

  • Install Node.js: get node with npm These two executable programs
  • Install Forge CLI: Get forge This executable
  • Check if the installation was successful

The way to determine your identity on a Linux system is to execute: whoamiIf the result is not rootIt means you are not root Account.

What if I am root?

For users using the Forge CLI on a cloud host. Because root User-installed tools can usually be shared by other users in the system, so the above steps can be used root Identity goes to completion.

Install Node.js

Because Forge CLI is developed using Node.js, you need to ensure that you have a Node.js runtime environment on your computer before installation. The easiest way to check if a Node.js runtime environment exists is:

If both commands have normal output (no command not found And other words and the output is not empty), it means that your computer already has the Node.js runtime environment.

Because some dependent libraries require no less than Node.js version v10.x, So it is also required when installing Forge CLI v10.x Node.js and above, if node --version The output is lower than v10.x, You need to reinstall or update to the new version.

Install Node.js under CentOS

Install Node.js on Ubuntu

Install Forge CLI

After installing the Node.js environment, you can directly execute the following command to install, pay attention to the--unsafe-perm It's required.

Check if the installation was successful

carried out forge --versionIf the version number of Forge CLI is output, the installation is successful.

Prepare a non-root account

Although you can install Forge CLI as root, you cannot execute any Forge CLI subcommands as root, and you cannot use root to create and start chain nodes. This is a security limitation of Forge. So in order to perform subsequent operations, we need to prepare a non-root identity:

Suppose the system account we want to use to execute the Forge CLI is named arcblockCan be divided into two steps:

  • Create user: execute adduser arcblock To add users
  • Switch user: execute su arcblock To switch to that user

Next, you can follow the tutorial Coin Issue

Video tutorial

The process of installing ForgeCLI under CentOS is as follows:

What if I'm not root?

For Mac systems or Linux systems with a graphical interface, the logged-in user is usually not root, and both Node.js and Forge CLI can be installed in the user's own directory.

Install Node.js

It is recommended that such users directly use NVM to install Node.js. NVM can automatically help you choose the version corresponding to your system. Here are the basic steps to install NVM first, and then install Node.js v10.16.3 using NVM and Taobao sources:

Install Forge CLI

After the Node.js environment is installed, you can directly install the Forge CLI with the following command:

If you are a Chinese user, installing the Forge CLI using Taobao's npm image may be faster. npm install -g @arcblock/forge-cli --registry https://registry.npm.taobao.org Just fine.

If you prefer to use yarn for installation, you can run yarn global add @arcblock/forge-cli To complete the installation.

Node.js and Forge CLI installed using NVM belong to the current user only, and cannot be accessed by other users of the system.

Check if the installation was successful

After the installation is complete, there will be one more in your system. forge Command line tool (The command generated after the Forge CLI installation is called forge Instead of forge-cli), Execute directly forge, No error is reported and you get the following output, indicating that you have successfully installed:

carried out forge help You can also get the output as above.

Video tutorial

The entire process of installing Node.js and Forge CLI as a non-root account is as follows:

How do I upgrade the Forge CLI?

The Forge CLI enables the automatic check for updates by default. When there is a new version, you will be prompted to update. If you do not pass Global configurationTurn off automatic check for updates and follow the prompts. If you need to update manually, you can override the update by executing the exact same command as installing.

  • If you are using root For account installation, switch to root Identity and then execute: npm install -g @arcblock/forge-cli --unsafe-perm
  • If you are not using root For account installation, execute directly under the corresponding account: npm install -g @arcblock/forge-cli Just

Common errors during installation

Installation failed with yarn?

If you use yarn After installation, execute forge The error is reported. The high probability is because grpc Library is not compiled successfully locally, at this time please try to use npm Go to install.

TODO: Need to update here


Can't wait to use the Forge CLI to send chains and coins? Continue to look down.