To resolve the error regarding root-owned files in your npm cache folder, you can follow these steps:
sudo chown -R $(whoami) ~/.npm
This command will recursively change the ownership of all files and folders inside the npm cache folder to your user account, resolving any permission issues.If you continue to encounter issues, consider updating npm to the latest version to ensure you're using the most stable release with the bug fixes.
export npm_config_cache=/path/to/cache
In Windows:
set npm_config_cache=/path/to/cache
This command worked for me:
sudo chown -R 1000:1000 "~/.npm"
I resolved the issue using the following method:
First, execute:
sudo npm cache clean --force
Then, remove the files owned by root. To view the file owners and groups:
cd /Users/username/
ls -la
Check the owner of .npm and change it to a non-root user:
sudo chown -R username:group "/Users/username/.npm"
Or for global .npm-global:
sudo chown -R username:group "/Users/username/.npm-global"
Simply updating the npm version and deleting the entire project did the trick.