Essentials
Getting Started
Artist Guides
CLI Setup
This page provides an introduction to the fx(hash) CLI - Command Line Interface - a helper tool that simplifies the development process of an fx(hash) project.
Whereas the Starting Template provided a simple and minimal starting point for creating new projects, the CLI will allow us to get a bit more hands on and provides a number of useful functionalities for the purpose of developing a project, running it locally, as well as testing it.
If you’re relatively new to programming, the learning curve of what follows might be a bit steep, as there's a number of new notions that we'll have to familiarise ourselves with, and will have to set up a couple of things on our machines. But we'll tackle one thing at a time. To provide a quick overview, in this section we will:
- Learn about Command Line Interfaces (CLIs)
- Learn a little about Node.js and the Node Package Manager (NPM) with which we’ll install the fx(hash) CLI
- Subsequently install the fx(hash) CLI
- Use the fx(hash) CLI to set up a blank fx(hash) project
What is a CLI?
A Command Line Interface (CLI) is a text-based interface for interacting with a computer via text commands. A CLI is also often referred to with the following terms: console, terminal, command line, command prompt. These terms can be used interchangeably.
CLIs stand in contrast to graphical user interfaces (GUIs) that most are familiar with, where we navigate and interact with the computer through visual elements like icons and buttons. A CLI relies on text-based commands and responses to do so.
Here's an example of what the terminal looks like on a Mac:
The terminal on Mac OS
You can often also find a terminal integrated within certain code editors like VSCode:
Terminal inside the VSCode editor
Within CLIs you can write specific commands to navigate directories, manipulate folders and execute certain programs:
For example, here we navigated to the Desktop directory via the cd
command, and then returned back to the parent user directory with cd ..
. These commands vary between different operating systems.
In this section we'll have a look at the fx(hash) CLI, a tool that provides a number of commands to help with the creation and development of fx(hash) projects - we'll cover how to install this CLI, explain some of the required tech that it needs to function, as well as how to get a project started with it.
Node.js and the Node Package Manager
To use the fxhash CLI we need to have node.js and the node package manager installed on our machine. If you're familiar with these tools and have used them before, you can skip to the next section for the installation instructions, if not, read on.
If this is your first encounter with node, here's a brief overview.
Node.js not a programming language, and it's also not a framework or library - but rather it's a runtime environment that allows you to run Javascript code outside of the browser. It is usually used to run Javascript code on backend servers to run javascript code server-side. Over the years it has become a popular and established tool for building various types of web applications.
NPM, is short for node package manager, and as the name suggests is used to install node packages made by third parties. These packages are bundles of Javascript code that solve specific problems or accomplish particular tasks - they're generally intended for reuse in other projects; you can think of them as lego blocks. The node package manager takes care of the distribution of these packages, and we’ll be using it to install the fx(hash) CLI that is itself a node package.
Overall, it's definitely a more advanced tool - it introduces a lot of new things that might take some practice to get used to. Although you don't actually need to know that much about Node to use the fxhash CLI (you can simply skip to the next section at this point) - if you want to learn more about what Node is and how it functions, the official node docs provide a slightly technical starting point:
If you want an alternative more lighthearted introduction to node in video format, we recommend this video by Fireship:
A quick guide to installing Node & NPM
Let's start with installing Node - there's a number of different ways to do so, the easiest of them being through the main website with an installer, you can find the official page here
Node installer
Otherwise you can install node via the terminal - the instructions for this can differ depending on what operating system you're working on. Since most users are probably running Windows or macOS, we'll cover these two scenarios. Instructions for installing Node on other types of operating systems can be found here.
Installing Node on Windows
Installing Node on macOS
Here we've got a couple of options, either via a curl command:
curl "https://nodejs.org/dist/latest/node-${VERSION:-$(wget -qO- https://nodejs.org/dist/latest/ | sed -nE 's|.*>node-(.*)\.pkg</a>.*|\1|p')}.pkg" > "$HOME/Downloads/node-latest.pkg" && sudo installer -store -pkg "$HOME/Downloads/node-latest.pkg" -target "/"
Or with via homebrew:
brew install node
In both cases simply copy paste the command to your command line and hit enter.
Checking your Install
To check if node has been installed correctly, run the following command from your terminal:
node -v
If it prints a number such as 21.0.0
to the console then you're good to go. If it tells you that the node command is not recognized, then something went awry.
Node & NPM Version Requirements
On last thing here, for the the fxhash CLI make sure that you have a node version higher or equal than 18.0.0
and and npm version higher or equal than 9.0.0
. You can check this via node -v
and npm -v
.
Setting up the fx(hash) CLI
If you’ve completed the previous steps, it means that you’re all set and you've successfully installed node.js and npm on your machine. We can now proceed to install the fx(hash) CLI with npm. This can be done with the following command:
npm i -g fxhash
The letter i
here simply stands for install
, and you could also equivalently write npm install -g fxhash
. Moreover, the -g
flag stands for global
, meaning that the package is installed globally on your system, making it such that the fx(hash) CLI tool can be run from anywhere on your system, without you having to reinstall the package every time you start a new project.
sudo
to the command should fix this. This will prompt you to enter your password.If you've completed the above steps you're done setting up - the fx(hash) CLI should now be installed on your machine and ready for you to use. In the next page we'll talk in more detail about using the fx(hash) CLI, use it to create a new project, and have a look at the other terminal commands it provides.
Running CLI commands with NPX
One last thing to point out here, is that once you've installed node.js you also get access to the npx command. In contrast to npm that installs packages on your system, npx lets you execute node packages directly without having to install them - meaning that you can directly set up a new fxhash project with:
npx fxhash create
By prepending the npx
command you can now run the the fx(hash) CLI command without having to install it with the npm i -g fxhash
command first, but this is simply a matter of preference.
← Previous
Next →