Skip to content

Error: EACCES: permission denied, scandir (Resolved)

Covers
File Permissions, npm
On this page

The “Error: EACCES: permission denied, scandir” error can also occur when using NPM (Node Package Manager) and trying to install a package. This is because NPM needs to access certain directories on your system, such as log files under the home directory or the global node_modules directory, and the error occurs when it doesn’t have the proper permissions to do so.

The Problem:

While running the npm command, I faced the following error message.

NPM error message:
glob error [Error: EACCES: permission denied, scandir '/root/.npm/_logs'] { errno: -13, code: 'EACCES', syscall: 'scandir', path: '/root/.npm/_logs' }

Generally, users receive this error, while running the npm commands with the root account. Here, we will discuss two solutions to resolve this error message.

Solution 1:

It is recommended not to run the npm command as the root account. This can be harmful to your system. So you can simply switch to a non-root account and run the same command.

Most probably this will resolve your issue.

Solution 2:

If you are bound to run the npm command as the root account. Then make sure the current working directory, in which you are running the npm command is owned by the root account.

So, change the current working directory (CWD) owner to root.

chown root:root . 

Then run your npm commands, and it should run without any error.

Conclusion

In summary, the “Error: EACCES: permission denied, scandir” error can occur when using NPM if the user does not have the proper permissions to access a specific directory. In this article, we have discussed two solutions to resolve this error on your system.

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top