DEV Community 👩‍💻👨‍💻

Cover image for How to Install Graph CLI On Ubuntu
Nuel geek
Nuel geek

Posted on

How to Install Graph CLI On Ubuntu

A few days ago, I got stuck trying to install Graph-cli on my Ubuntu operating system. I had to make a lot of research to figure it out, and I did with the help of my peers too.
In this article, I will be sharing how to install Graph-cli on Ubuntu, and this will be a quick one.

The Graph CLI is written in JavaScript, and you will need to install either yarn or npm to use it; it is assumed that you have yarn in what follows. Once you have yarn, install the Graph CLI by running,

For Ubuntu, install with yarn or npm:

sudo yarn global add @graphprotocol/graph-cli
Enter fullscreen mode Exit fullscreen mode

The sudo keyword gives the dependencies root access to your OS

Other Methods on Linux
libsecret is used for storing access tokens, so you may need to install it before getting started. Use one of the following commands, depending on your distribution:

Debian/Ubuntu:

sudo apt-get install libsecret-1-dev
Enter fullscreen mode Exit fullscreen mode

Red Hat:

sudo yum install libsecret-devel
Enter fullscreen mode Exit fullscreen mode

Arch Linux:

sudo pacman -S libsecret
Enter fullscreen mode Exit fullscreen mode

For other OS, install with yarn or npm:

yarn global add @graphprotocol/graph-cli
Enter fullscreen mode Exit fullscreen mode

Once installed, the graph init command can be used to set up a new subgraph project, either from an existing contract on any of the public Ethereum networks or from an example subgraph. This command can be used to create a subgraph on the Subgraph Studio by passing in graph init --product subgraph-studio.

If you already have a smart contract deployed to the Ethereum mainnet or one of the testnets, bootstrapping a new subgraph from that contract can be a good way to get started.

Learn more about creating and deploying subgraph here.

Top comments (0)

🌚 Browsing with dark mode makes you a better developer.

It's a scientific fact.