Resolved Error: EACCES: permission denied, access '/usr/local/lib/node_modules'

[Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] { errno: -13, code: 'EACCES', syscall: 'access', path: '/usr/local/lib/node_modules'}

🙋‍♂️ Shubham Verma    🗓 July 24, 2020


Resolved Error: EACCES: permission denied, access '/usr/local/lib/node_modules'


S

ometime, while installing anything using npm, you can see the Error: Error: EACCES: permission denied, access '/usr/local/lib/node_modules' on your CMD or Terminal who prevent the installation. In this article we will see about the issue "EACCES: permission denied".

Resolved Error: EACCES: permission denied

In this article, we will resolved the error: EACCES: permission denied, access \'/usr/local/lib/node_modules\', This error comes due to the correct permission of files or folder to do any specific operation like READ, WRITE etc.',

Here I am trying to install the angular CLI but I was getting the error as:


see the below snapshot:

Error: EACCES: permission denied, access '/usr/local/lib/node_modules'

Error: EACCES: permission denied, access '/usr/local/lib/node_modules'


Resolve 'EACCES: permission denied' problem:

First you should check the file/folder permission by running below command:

ls -la /usr/local/lib/node_modules

See the snapshot:

Error: EACCES: permission denied, access '/usr/local/lib/node_modules'

Error: EACCES: permission denied, access '/usr/local/lib/node_modules'

You can see in the above snapshot, it is denying access just because of the node_module folder is owned by root


Now this permission needs to be changed by changing the root to your user, you need to know the current username of your system.
To get the username run the below command:

or


Now you can see the current username as: Error: EACCES: permission denied, access '/usr/local/lib/node_modules'

Error: EACCES: permission denied, access '/usr/local/lib/node_modules'

Change the user:

Now its time to change the user (owner) and remove the problem.
To change the user (owner) of this folder, run the below command:


eg:

After this command, it will ask for password, enter the password and you'r done.

To confirm, check the below command to see the permission and user of that file/folder ( as you did earlier ):

ls -la /usr/local/lib/node_modules

See the snapshot:

Error: EACCES: permission denied, access '/usr/local/lib/node_modules'

Error: EACCES: permission denied, access '/usr/local/lib/node_modules'


Now your problem should be solved, let's check by installing the angular CLI:

See the snapshot:

Error: EACCES: permission denied, access '/usr/local/lib/node_modules'

Error: EACCES: permission denied, access '/usr/local/lib/node_modules'

In the above image, you can see the Error: EACCES: permission denied, access '/usr/local/lib/node_modules' is resolved now.


Conclusion:

In this article, we saw how we can resolve the Error: EACCES: permission denied, access '/usr/local/lib/node_modules' problem and we can change the permission of any file/folder and also saw how we can get the current username of the system.



Support our IDKBlogs team

Creating quality content takes time and resources, and we are committed to providing value to our readers. If you find my articles helpful or informative, please consider supporting us financially.

Any amount (10, 20, 50, 100, ....), no matter how small, will help us continue to produce high-quality content.

Thank you for your support!




Thank you

I appreciate you taking the time to read this article. The more that you read, the more things you will know. The more that you learn, the more places you'll go. If you’re interested in Node.js or JavaScript this link will help you a lot.

If you found this article is helpful, then please share this article's link to your friends to whom this is required, you can share this to your technical social media groups also. You can follow us on our social media page for more updates and latest article updates.
To read more about the technologies, Please subscribe us, You'll get the monthly newsletter having all the published article of the last month.