'uninstalling broken node packages for react native

I am working on a react native app and I had to install node and expo-cli to start the app but recently I have been having issues with running the app. When I run npm start, I get the error expo: command not found so I install the expo-cli using npm install --global expo-cli I get this error:

npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /Users/{usr}/.npm-global/lib/node_modules/expo-cli
npm ERR! dest /Users/{usr}/.npm-global/lib/node_modules/.expo-cli-F3yBqKce
npm ERR! errno -13
npm ERR! 
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR! 
npm ERR! To permanently fix this problem, please run:
npm ERR!   sudo chown -R 501:20 "/Users/{usr}/.npm"

I ran the sudo chown -R 501:20 "/Users/{usr}/.npm command but it still does not work.

So I tried to uninstall node and start all over but the issue still persists. Does anyone know a way to fix these issues? Like is there a way I can reset my packages or something like that?

Thanks in advance!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source