Windows defender or antivirus software can cause this exact issue. I encountered something similar where my real-time protection was scanning files as npm tried to rename them, creating a lock that prevented the operation. Try temporarily disabling your antivirus real-time scanning during the install process. Another approach that worked for me was deleting the entire node_modules folder and package-lock.json file before running npm install again. Sometimes Windows file indexing service also interferes with file operations in heavily nested directories like node_modules, so pausing that service temporarily might help resolve the permission conflict.
try running npm install --no-optional which skips optional dependecies that sometimes cause rename issues. also check if you have onedrive or dropbox syncing your project folder - they can lock files during sync. i switched to yarn and it handled these windows permission problems much better tbh.
This EPERM error typically occurs when Windows locks files during the npm installation process. I had this exact same issue on my development machine and found that running the command from a different location sometimes works. Try opening PowerShell or Command Prompt in a directory with a shorter path, like C:\temp, then navigate to your project folder from there. The deeply nested node_modules structure can exceed Windows path length limitations which triggers permission errors. Another solution that helped me was setting npm’s cache directory to a location with full write permissions using npm config set cache C:\npm-cache --global. If you’re using Visual Studio Code or any IDE, make sure to close it completely before running npm install as editors sometimes maintain file handles on node_modules contents even when not actively displaying them.