Erorr using NPM package manager: EPERM: operation not permitted, rmdir.

Stellar 0 Reputation points
2023-12-23T23:24:29.0366667+00:00

Problem

When using the NPM package manager, I encountered the EPERM: operation not permitted, rmdir error. This error occurs in different scenarios when using NPM, such as when it needs to delete temporary files.

Scenario 1: Installing/Uninstalling NPM packages.

enter image description here

Scenario 2: The use of electron-forge, whose purpose is to compile Electron applications, utilizes the system's temporary file directory.

enter image description here

I have tried various solutions provided by the NPM, Node, and Electron-Forge communities, including:

  • Running the process as both an administrator and a regular user.
  • Executing npm cache clean --force and npm cache verify.
  • Changing the TEMP path to a location on a non-system drive.
  • Rebooting the computer under different states.
  • Attempting to use YARN, resulting in the same error.
  • Shuting down Node process. (There were no blocking processes using the folder that needed to be deleted. Tested using handle64.exe & Process Explorer)
  • Adjusting versions of Node, NPM, and Electron-forge with combinations such as:
    • Node: v21.5.0, v20.10.0, v18.19.0, v9.11.2.
    • NPM: v10.2.3, v4.x.x, v5.x.x.
    • Electron-forge: v6.0.x.

Research

In an effort to resolve the issue, I attempted to delete the empty folder created by electron-forge in the TEMP directory using rmdir <path>. However, I encountered the error Access is denied., despite being an administrator with the necessary permissions. I can use the rmdir command to successfully remove an empty folder, but this does not apply to the one created by electron-forge or NPM-like packages or NPM itself. It's puzzling how this operates. Interestingly, using rmdir /s /q <path> successfully removes the folder. Also tested in another Windows 11 Pro system which does not have a similar problem.

Specs:

  • OS Name: Windows 11 Home
  • System Type: x64-based
  • Device: Vivobook_ASUSLaptop X1403ZA_X1403ZA
Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-12-27T01:15:52.25+00:00

    Hello,

    Thank you for posting in Q&A forum.

    As you have tried several suggestions from other forums, we will provide you some steps to try from Windows OS side to see if it can help you further:

    1. Run command in CMD Window as an administrator trying to delete the folder.
    2. Try again when disabling any other 3rdparty antivirus/security software.
    3. Check file and folder permission:

    Make sure that the user account you are using has permission to modify and delete files in the temporary directories.

    To do this, right-click on the folder, select Properties, go to the Security tab, click on Edit to change Permissions, select the user, and give Full Control to that user.

    1. Check compatibility:

    Check if the version of any tool you mentioned is compatible with current Windows 11 version.

    You can also try to test with another Windows10/11 machine.

    1. Check environment variables:

    Check the TEMP and TMP environment variables and make sure they point to locations where your user account has full control.

    Hope this answer can help you well.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.