PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, May 14, 2022

[FIXED] How to install graph-cli on Ubuntu?

 May 14, 2022     graph, ubuntu     No comments   

Issue

I want to install @graphprotocol/graph-cli on Ubuntu. I have tried to install graph-cli with npm and yarn, both of them.

# NPM
npm install -g @graphprotocol/graph-cli

# Yarn
yarn global add @graphprotocol/graph-cli

But after that when I tried graph init, I met this error bash: /usr/bin/graph: No such file or directory.

What can I do? What was my fault?

Is anybody help me with this issue?


Solution

The error is telling you that it cannot find the file to execute. It tries to find the executable file by searching the PATH environment variable.

Make sure that @graphprotocol/graph-cli did successfully install first and no error occurred. You can do this by trying the install command again.

You can get this PATH variable with the following line: echo $PATH

When you install something globally with npm (-g flag). It puts it in its own directory. In my case, this is /home/timothy/.nvm/versions/node/v16.13.1/bin (I'm using node version manager (nvm))

It will be different for you, and you need to find out where your npm installation puts these. You can find it an approximate location with

whereis npm

or

npm config ls -l | grep prefix (the one which says only prefix; as described here: https://stackoverflow.com/a/43398997/11781125)

Remember to make sure this path usually ends in /bin and add this to your PATH variable like this (example with my path):

export PATH=$PATH:/home/timothy/.nvm/versions/node/v16.13.1/bin

Try to run the command again in the same terminal that you put the above command (adjusted to your path). If this resolves the issue, add it permanently by adding the same line to your ~/.bashrc. The following command will do this, but you can also just open an editor (again example with my path; adjust it):

echo "export PATH=\$PATH:/home/timothy/.nvm/versions/node/v16.13.1/bin" >> ~/.bashrc

Putting the command there will inject it when opening a terminal (for bash, that is).



Answered By - Timothy L Gillespie
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing