Error eacces permission denied access usr local lib

npm http GET https://registry.npmjs.org/coffee-script npm http 304 https://registry.npmjs.org/coffee-script npm ERR! Could not create /usr/local/lib/node_modules/___coffee-script.npm npm ERR! error...

I am REALLY new to this and I am bit old for this! lol anyway… I am trying to do this npm install -g @bigcommerce/stencil-cli
and is giving a bunch of errors….

Anas-iMac:~ anacuenca$ npm install -g @bigcommerce/stencil-cli
npm WARN deprecated github@8.2.1: ‘github’ has been renamed to ‘@octokit/rest’ (https://git.io/vNB11)
npm WARN deprecated coffee-script@1.7.1: CoffeeScript on NPM has moved to «coffeescript» (no hyphen)
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to «coffeescript» (no hyphen)
npm WARN deprecated npmconf@2.1.2: this package has been reintegrated into npm and is now out of date with respect to npm
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated graceful-fs@1.2.3: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated good-reporter@3.1.0: This module is no longer being maintained and is no longer needed for custom Good reporters.
npm WARN deprecated nomnom@1.8.1: Package no longer supported. Contact support@npmjs.com for more info.
npm WARN deprecated graceful-fs@3.0.11: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
npm WARN deprecated es6-module-loader@0.16.6: This project has been deprecated for «npm install es-module-loader» based on the newer loader spec.
npm WARN deprecated formatio@1.2.0: This package is unmaintained. Use @sinonjs/formatio instead
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm WARN eslint-config-airbnb@6.2.0 requires a peer of eslint-plugin-react@^4.2.3 but none is installed. You must install peer dependencies yourself.

npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’
npm ERR! { Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’
npm ERR! stack: ‘Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules»,
npm ERR! errno: -13,
npm ERR! code: ‘EACCES’,
npm ERR! syscall: ‘access’,
npm ERR! path: ‘/usr/local/lib/node_modules’ }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/anacuenca/.npm/_logs/2018-03-14T22_28_04_564Z-debug.log
Anas-iMac:~ anacuenca$ npm install -g coffee-script
npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to «coffeescript» (no hyphen)
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’
npm ERR! { Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’
npm ERR! stack: ‘Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules»,
npm ERR! errno: -13,
npm ERR! code: ‘EACCES’,
npm ERR! syscall: ‘access’,
npm ERR! path: ‘/usr/local/lib/node_modules’ }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/anacuenca/.npm/_logs/2018-03-14T22_34_34_674Z-debug.log
Anas-iMac:~ anacuenca$ npm install -g coffee-script
npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to «coffeescript» (no hyphen)
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’
npm ERR! { Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’
npm ERR! stack: ‘Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules»,
npm ERR! errno: -13,
npm ERR! code: ‘EACCES’,
npm ERR! syscall: ‘access’,
npm ERR! path: ‘/usr/local/lib/node_modules’ }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/anacuenca/.npm/_logs/2018-03-14T22_35_52_567Z-debug.log
Anas-iMac:~ anacuenca$ ;2Croot/Administrator
-bash: syntax error near unexpected token `;’
Anas-iMac:~ anacuenca$ ..
-bash: ..: command not found
Anas-iMac:~ anacuenca$
any idea why?

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.


Strongly Recommended Books For You:

Reading books opens the door to allow in more lights, If we want to know a man of rare intellect, try to know what books he/she reads.

For India:

For Other Countries (United States, United Kingdom, Spain, Italy, Germany, France, Canada, etc)


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.

The permission error ‘EACCES permission denied access, /usr/local/lib/node_modules’ occurs in most cases when the user may have installed npm using a Node installer (which is not recommended since npm will be installed in a directory with local permissions which can give rise to permission errors in case npm packages are run globally, see documentation).

To fix the issue, you would need to use nvm to reinstall it (without suppressing npm).

Open up your terminal and run the command below:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

Next invoke the command :

nvm install stable

Which will install the package npm as well as node.js.

Read: How to install Node.js on Linux/Ubuntu

There is no need to modify the permissions.

You may want to refer to npm official page for more information.


If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.

amin nahdy

Amin Nahdy, an aspiring software engineer and a computer geek by nature as well as an avid Ubuntu and open source user. He is interested in information technology especially Linux based ecosystem as well as Windows and MacOS. He loves to share and disseminate knowledge to others in a transparent and responsible way.

Ezoic

In this post, we will look at an easy fix for Missing Write Access error when we try to install some NPM package globally.

More often than not, this issue happens when we have setup NPM for the first time on any host machine and we try to install some package globally. It is mainly a permissions related issue and usually happens for Mac or Linux machines.

1 – The Error Message

The message itself might appear as below depending on the package in question.

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm WARN ajv-keywords@3.5.2 requires a peer of ajv@^6.9.1 but none is installed. You must install peer dependencies yourself.

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

Basically, the issue here is that the user executing the command does not have write access to the folder /usr/local/lib/node_modules.

2 – The Fix for Missing Write Access

The fix for this issue is actually quite simple. We have to run the below command:

sudo chown -R $USER /usr/local/lib/node_modules

Let’s decode this command:

  • The sudo means we want to run this command as root i.e. the system super user. This is because we don’t have permission to write to the folder but the root user can fix any permission issues. While executing the command, you will be prompted for the password.
  • Next, we have chown. This command changes the ownership of a file or folder. The -R flag specifies that we want to change the ownership recursively. In other words, the owner access will be given to all the sub-folders and files.
  • $USER is an environment variable that is automatically set to your user id.
  • Finally, we have the folder path of which we wish to change the ownership.

After we run this command, our user will have ownership on the folder /usr/local/lib/node_modules.

Now, we can run the npm install command again to install the required package.

Important point to pay attention to the folder name in the error message. If it’s different, you need to update accordingly in the chown command.

Conclusion

And that’s about it.

Though the error looks quite complicated, it is actually very easy to solve it. We have seen a simple command to fix the issue and continue with installing the packages.

If you have any comments or queries, please feel free to write in the comments section below.


Saurabh Dashora

Saurabh is a Software Architect with over 12 years of experience. He has worked on large-scale distributed systems across various domains and organizations. He is also a passionate Technical Writer and loves sharing knowledge in the community.

Dung Do Tien Sep 26 2021 597

Hello guys. I am beginner in Nodejs. I have create a small project with Node and when I run and get an exception throw Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’.

 npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/macbookmd101/.npm/_logs/2021-09-21T16_26_08_421Z-debug.log

I am using node version 12.18.3. and OS Linux Ubuntu 18.04

Thanks for any suggestions.

Have 3 answer(s) found.

  • You need allow access to some folder as below:

     sudo chown -R $USER /usr/local/lib/node_modules/
    sudo chown -R $USER /usr/local/bin/
    sudo chown -R $USER /usr/local/share/

    Allow access only to node_modules folder might be your issue not be solved.

    I hope this answer useful for you.

  • Nguyen Quang Thai
    Sep 26 2021

    I think your account is not root account so you not have permission to access.

    You can change change owner permision, you can run command:

     sudo chown -R [owner]:[owner] /usr/local/lib/node_modules

    Or

     sudo chown -R ownerName: /usr/local/lib/node_modules

    Or

     sudo chown -R $USER /usr/local/lib/node_modules

    I hope it solve error for you.

  • You can try run command below to help access to root account:

    It maybe request access your password.

Photo from Unsplash

When you try to install an npm package globally using the npm install -g <package name> command, you may find the following error:

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules

The warning above means that your current terminal user doesn’t have “write access” to the /usr/local/lib/node_modules folder.

Because you can’t write any new file and folder to the node_modules folder, npm won’t be able to complete the installation.

You should see other errors below the warning as a consequence of the warning:

npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/rimraf
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, ...
npm ERR! 
npm ERR! The operation was rejected by your operating system.

Without the write access, npm will not be able to create folders and write the files for the package you are trying to install.

There are three ways to fix this error:

This tutorial will help you resolve the missing write access error.

Installing npm modules globally with the sudo command

You can run the npm install command as root user by adding sudo before the command:

sudo npm install -g @angular/cli

The sudo command allows you to execute terminal command as the “root” user. You will be asked for your password when you invoke this command.

By calling the sudo command, the error message with code EACCES should be resolved because root user has access to everything on your computer.

The drawback of this method is that you also need to add sudo when you want to uninstall the package later.

As an alternative, you can change the owner of the node_modules folder instead

Fix missing write access using chown command

The first way is to change the owner of the node_modules folder, which must be owned by user “root” by default.

The following command will change the owner of the folder to your current user. I will explain the command below:

sudo chown -R $USER /usr/local/lib/node_modules

The chown command is used to change the owner of the folder.

The -R option means that the change owner command will be executed recursively, changing not only the node_modules folder owner, but also the rest of the files and folders inside it.

Then, the $USER is an environment variable that will be replaced with the current username you used to login to your computer.

Finally, the folder path /usr/local/lib/node_modules is included to tell the terminal to change the owner of that folder.

By running the command above, you will be able to install npm packages again because the node_modules folder now belongs to your current user.

But rather than running the command and changing the owner of the folder, I’d recommend you install NVM instead.

Fixing missing write access using NVM

NVM or Node Version Manager is a software that’s designed to be installed per-user basis.

It allows you to install multiple versions of NodeJS on your computer so that you can upgrade or downgrade your NodeJS version as needed.

The reason why using NVM would fix the missing write access command is that by default, NVM will install NodeJS versions to a folder under your current user.

For example, my NodeJS version is currently installed under the /Users/nsebhastian/ folder:

nvm which current
/Users/nsebhastian/.nvm/versions/node/v10.19.0/bin/node

When you install global packages using NVM, the package will be installed under the version’s lib/ folder:

/Users/nsebhastian/.nvm/versions/node/v10.19.0/lib/node_modules

By using NVM, you will have the ability to install different versions of NodeJS on your computer and you will automatically fix the missing write access error. I’m currently using it for my computer, and I’d recommend you to use it too 😉

You can learn how to install NVM here

Now you’ve learned how to resolve the permission denied error message caused by missing write access. Nice work! 👍

Понравилась статья? Поделить с друзьями:
  • Error e161 403e
  • Error e019 street cannot intersect with itself split this element
  • Error e011 духовка siemens
  • Error e01 epson
  • Error e0046 processing failed no calibrated cameras