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?
CodePudding user response:
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).