简体   繁体   中英

Permission denied after installing Ganache with npm

I'm using ubuntu and installed node via nvm .

nvm --version   
0.39.1
nvm list 

       v16.13.2
->      v17.4.0
default -> v16.13.2 (-> N/A)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v17.4.0) (default)
stable -> 17.4 (-> v17.4.0) (default)
lts/* -> lts/gallium (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.9 (-> N/A)
lts/fermium -> v14.18.3 (-> N/A)
lts/gallium -> v16.13.2 (-> N/A)
  
npm --version  
8.3.2

I have $NVM_DIR configured:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This load>

export PATH="$PATH:/home/helio/.nvm/versions/node/v17.4.0/bin"

I installed Ganache with:
npm install --global ganache
and it's under:
.nvm/versions/node/v17.4.0/bin/ganache

But when I run for example:
ganache --port 8545 --gasLimit 12000000 --accounts 10 --hardfork istanbul --mnemonic brownie
I get:
bash: /home/helio/.nvm/versions/node/v17.4.0/bin/ganache: Permission denied

When I look up for this error the solution always ends up installing node via nvm so everything will go under .nvm .

Can someone help me understand what am I missing?

Looks like you've used sudo to install something globally before. You probably shouldn't be using sudo with npm or yarn .

I know it sounds extreme, but if you've used sudo in order to install npm packages and don't understand the ramifications of doing so (it allows the package author, or any of the authors of dependencies that package relies on to do anything everything they desire with your system; they could install backdoors or even update your bios if they wanted to). You may want to consider formatting your hard drive, resetting your bios, and reinstalling your operating system if you've made a habit of doing this.

Using sudo with the global flag ( -g ) also changes your npm folder's permissions, which causes issues like you are seeing above. If you don't want to follow my suggestion to reset your system, npm has an article on how you can try to fix npm's permissions: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM