npm install near-cli -g I was getting the following error:
npm ERR! code 128 npm ERR! command failed npm ERR! command git ls-remote ssh://email@example.com/ethereumjs/ethereumjs-abi.git npm ERR! Warning: Permanently added 'github.com' (RSA) to the list of known hosts. npm ERR! firstname.lastname@example.org: Permission denied (publickey). npm ERR! fatal: Could not read from remote repository. npm ERR! npm ERR! Please make sure you have the correct access rights npm ERR! and the repository exists.
It was an authentication problem with GitHub. One possible solution was to create a new SSH key, add it to the
ssh-agent and to my GitHub account. I did it but didn't work as I was getting a different error, even if I was running the command as the
npm ERR! code 128 npm ERR! command failed npm ERR! command git clone ssh://email@example.com/ethereumjs/ethereumjs-abi.git /root/.npm/_cacache/tmp/git-clone-e04f6db7 --recurse-submodules --depth=1 npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-e04f6db7': Permission denied
I tried to install
near-cli on a virtual environment with Fedora 32 where the latest version of Node.js was 12.22.1, it worked without any problem. On Fedora 33 and Debian Buster I was getting the same error.
Manually change npm's default directory, according to the Node.js documentation, is the way of Resolving EACCES permissions errors when installing packages globally.
After installing Node.js and npm:
Create a directory for global installations:
$ mkdir ~/.npm-global
Configure npm to use the new directory path:
$ npm config set prefix '~/.npm-global'
Open or create a
~/.profile file and add this line:
Update your system variables:
$ source ~/.profile
Now you can install
near-cli by running the following command without
$ npm install near-cli -g
You're good to go! Now you have the tool you require for completing the exercises at Near Academy.