EACCES error fix: Everything you need to know

Joshua NwankwoJoshua Nwankwo
3 min read

Hey there! Have you ever come across an EACCESS error while installing a package, editing a file, or accessing a file/directory? It can be pretty frustrating, right? Sometimes adding sudo to your command does the trick, but other times it just doesn't seem to work. I know the feeling because I recently faced a similar issue and it took me a while to figure out what was causing the error and how to fix it. But don't worry, I've got you covered! In this article, I'll be sharing with you exactly what I did to fix the error.

Cause of the error?

Firstly, we need to understand why we are getting the error in the first place, as the error message state, this is a permission error, we are not able to write to that particular directory

What is file permission?

For us to understand what is happening, we need to understand file permission and how it works so let's get into that!

File permissions control access and actions on files, crucial for system security and file integrity.

There are three fundamental permissions for every file: read, write, and execute. Read permission enables a user to see the file's contents, write permission lets them modify the file, and execute permission permits them to use the file as a program.

So, there are three types of users that can have different levels of permission for different types of permissions. These are the file owner, the group the file belongs to, and all other users. Easy peasy!

For example, the file owner may have read and write permissions, the group may have only read permission, and all other users may have no permissions at all. This would mean that only the owner of the file can make changes to it, members of the group can view the file but not make changes, and all other users are unable to access the file at all.

Understanding file permissions is an important part of managing your system and keeping your files safe and secure.

| Permissions Description | Octal Value     | File Permissions Set     |
| :---------------------- | :-------------: | -----------------------: |
| No access               |       0         |           ---            |
| Execute                 |       1         |           --x            |
| Write                   |       2         |           -w-            |
| Write and execute       |       3         |           -wx            |
| Read                    |       4         |           r--            |
| Read and execute        |       5         |           r-x            |
| Read and write          |       6         |           rw-            |
| Read, write and execute |       7         |           rwx            |

Source: Macstadium

Solution

Now we've learned a bit about file system permission let's now navigate to the path where our package is trying to get installed and find out if we have written permission.

As you can see, we don't have permission to write to node_module, now we know the cause of our problem let's go ahead and fix it!

Let's check again if we now have to write access by running the following command

Cool, now we have permission to write, let's go ahead and put it to test

As you can see our package is now successfully installed!๐ŸŽ‰๐Ÿฅณ

Summary

This article explains the EACCES error, which is a permission issue that occurs when a user is unable to write to a directory. It provides an overview of file permissions, how to check for permission issues and a step-by-step guide on how to fix the error. Additionally, it offers tips and advice for readers.

DID YOU KNOW?

Hey, before you leave, I have a cool tip for you! Did you know that you can actually like one article up to 10 times? Why not give it a go and click that like button multiple times ๐Ÿ˜‰. Now you know! Also, I'd love to hear your suggestions on what you want me to write about next. Until next time, take care and peace out!

11
Subscribe to my newsletter

Read articles from Joshua Nwankwo directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Joshua Nwankwo
Joshua Nwankwo

Contributing my best to web3 adoption