3

I've already installed ganache-cli with sudo npm install -g ganache-cli on my MacOS but I am not able to interact with it through my terminal.

I always get the error: -bash: ganache-cli: command not found.

Maybe it isn't installed on the right PATH?

Would be glad for help. The normal version of Ganache is working properly on my computer, but with that, I cannot fork the blockchain.

1
  • I am having a similar issue, though I installed ganache through: yarn global add ganache-cli instead of through npm and on Fedora. I'm following along through a tutorial, so I'm really surprised the above didn't work. Dec 10, 2021 at 16:37

1 Answer 1

2

You should (almost) never use sudo with npm. Once you do so the folders and files npm touches/creates are now locked to the root user only.

The simplest solution is to do sudo rm -rf node_modules for whatever project you are currently in. Similarly, you may have to do something akin to sudo rm -rf $(npm prefix -g)/{bin,lib/node_modules} in case you globally installed node modules with the wrong prefix. Just be aware that this will remove libraries you installed with sudo before, so you will have to install them again. The right way.

More specifically pay attention to the output. Read what npm is telling you and find the directory that is causing a problem specifically. Remove it. If you can't remove it, you'll have to use sudo rm. Ultimately you should be able to do an npm install or npm install -g without using sudo.

(from https://medium.com/@ExplosionPills/dont-use-sudo-with-npm-5711d2726aa3)

Aside: Ganache UI does allow you to use the forking feature:

Ganache UI forking

1
  • @Royal.Flush, feel free to upvote the answer if you found it helpful. Jan 12, 2021 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.