I installed truffle through npm
with the following:
sudo npm install -g truffle
but when I run truffle list on the console it just gives me
bash: truffle: command not found
I installed truffle through npm
with the following:
sudo npm install -g truffle
but when I run truffle list on the console it just gives me
bash: truffle: command not found
I had a similar problem. I ran npm i -g truffle
and then when I tried to run truffle init
I got an error: zsh: command not found: truffle
. What solved it for me is to create a local node_modules with truffle installed in it, and then run that copy.
npm init
and make a new npm projectnpm i truffle
./node_modules/.bin/truffle init
and it should work!Please make sure you have the latest version of npm and node installed. I had the same issue, I updated npm and node to latest version and it worked.
npm install -g truffle
works.
After installing truffle:
npm install -g truffle
Run on your project folder:
npx truffle init
I did it on a Virtual box and had the same issue, but it worked after I restarted the computer. Hopefully that works for you too
You should add the following to your path
system variable.
C:\Users\UserName\AppData\Roaming\npm
(This folder contains the truffle.cmd
file)
I have tried and it works.
I tried everything. Followed the instruction on official truffle website and above answers. Still it didn't seem to worked.
Finally, this worked for me.
Go to C:\Users\Username\AppData\Roaming\npm
There you will find truffle.cmd
Double click on it and your done.
npm i truffle
does the exact same thing as npm install -g truffle
except that installs it globally, and without -g
it will be installed on the local folder. Try to update the npm, node, and probably you have a broken node installation from previous versions.
Nothing above worked for me, but I did:
Try to start with your command like
npx truffle <your command>
You should add C:\Users\UserName\AppData\Roaming\npm
(it contains truffle.cmd file) to the path user variables. I have tried and it works
If you have a custom path for your packages, then make sure that you are exporting it when the terminal loads.
For bash:
nano ~/.profile
For zsh:
nano ~./zshrc
And add your custom path, most of the time this will be "npm-global".
export PATH=~/.npm-global/bin:$PATH
1- Configure npm
to install software globally in your home directory as follows :
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
2- If you are using bash
, then execute the following:
echo -n "export PATH=~/.npm-global/bin:$PATH" >> ~/.profile
However, if you are using zsh
instead, then execute the following command:
echo -n "export PATH=~/.npm-global/bin:$PATH" >> ~/.zshrc
Note that, if you are using both bash
and zsh
, it is better to execute the two commands above.
I solved this problem by doing the following commands:-
npm uninstall -g truffle
sudo npm install -g truffle
Be aware when using sudo(root)
Then it works when I use the below command
truffle init
in my dir. Basically it will bootstrap