Ganache-cli: install -g ethereumjs-testrpc: permission denied

Created on 20 Jun 2017  路  8Comments  路  Source: trufflesuite/ganache-cli

trying to install with npm on OSX (Sierra 10.12.5):

$ sudo npm install -g ethereumjs-testrpc

I get the npm error:

npm ERR! code 1
npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b master https://github.com/debris/bignumber.js.git /Users/xxxxx/.npm/_cacache/tmp/git-clone-b4c1ee5c
npm ERR! /Users/xxxxx/.npm/_cacache/tmp/git-clone-b4c1ee5c/.git: Permission denied

Which permission? Does anybody know why, please let me know.

Thanks,
Bernhard..

Most helpful comment

You should never install npm modules with sudo (not even global ones). I would recommend you to uninstall node completely (and all global dependencies) and reinstall it through homebrew by running brew install node. This will set permissions properly and you won't need to use sudo for any installation.

If you want to have a different version of node: npm i -g n and e.g. n 6.9.5. Use n ls to see all available versions.

After that, rerun npm i -g ethereumjs-testrpc.

All 8 comments

I found out how to set the right permissons:

$ sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}

$ sudo chown -R $(whoami) "$HOME/.npm"

$ npm cache verify

Now, all npm installs should work

Helpfull links:

I also have this problem, but your fix doesn't work for me.

You should never install npm modules with sudo (not even global ones). I would recommend you to uninstall node completely (and all global dependencies) and reinstall it through homebrew by running brew install node. This will set permissions properly and you won't need to use sudo for any installation.

If you want to have a different version of node: npm i -g n and e.g. n 6.9.5. Use n ls to see all available versions.

After that, rerun npm i -g ethereumjs-testrpc.

@kevin-smets solution worked for me

NOENT: no such file or directory, access '/usr/local/lib/node_modules/ganache-cli'

Closing due to inactivity/age

@BLukassen or anyone finding this issue after the fact - your best bet to avoid permissions issues in node is to use NVM. Windows users should check out nvm-windows or nodist. I personally use nvm-windows on windows machines, and I haven't tried nodist.

cc @jbarros35. Also homebrew also works great on mac (per @brdtrpp), but my preference is still to use NVM over homebrew because it supports rapid switching of node versions with a different version per terminal session if desired.

Was this page helpful?
0 / 5 - 0 ratings