Installing Node with NVM prevents permission errors when installing NPM packages globally.
Install NVM.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.9/install.sh | bash
Close, quit, and reopen the terminal.
Make sure it installed correctly.
nvm –version
Install and use the latest version of node.
nvm install node
nvm use node
Now, we can install npm packages globally without any permission errors and without using sudo.
npm install -g react-native-cli