Lately I'm getting the "EPERM: operation not permitted" error in Visual Studio Code while working on my SvelteKit project. It also happens on new projects. The error occurs randomly (when using npm commands, deleting folders, moving folders etc.). I'm working on a clean installed Windows 11 laptop and had no issues with my previous laptop (same projects/same directories etc.)
A list of random errors:
[npm WARN cleanup 'C:\Webdev\svelte-app-capacitor2\node_modules\.p-limit-b0Htm7uU',npm WARN cleanup [Error: EPERM: operation not permitted, rmdir 'C:\Webdev\svelte-app-capacitor2\node_modules.p-limit-b0Htm7uU'] {npm WARN cleanup errno: -4048,npm WARN cleanup code: 'EPERM',npm WARN cleanup syscall: 'rmdir',npm WARN cleanup path: 'C:\Webdev\svelte-app-capacitor2\node_modules\.p-limit-b0Htm7uU'npm WARN cleanup }npm WARN cleanup ],
PS C:\Webdev\svelte-app-capacitor2> npm run dev -- --host> svelte-app@0.0.1 dev> vite dev --hostForced re-optimization of dependencieserror when starting dev server:Error: EPERM: operation not permitted, rmdir 'C:\Webdev\svelte-app-capacitor2\node_modules\.vite\deps'
× copy android - failed![error] Error: EPERM: operation not permitted, rmdir'C:\Webdev\svelte-app-capacitor2\android\app\src\main\assets\public\audio'
I did a lot of research and did the following (without results):
- Granted the right permissions on the folder(s) (full controll)
- Run Visual Studio Code as admin.
- Check for Node.js Version Issues
- Using CMD instead of Visual Studio Code
- Delete node_modules and npm install the project again (this works the best, but for short times)
- Adjusted my Antivirus and granted permissions for the folders.
- Enabled Long Path Support.
- Checked Disk(chkdsk /f)