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

How we solve Error: EACCES: permission denied erros and more solutions from other sources that may work for you.

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

If you run into this type of error, this solution is how i solved it . Just run this command in your term :

sudo npm install -g @ angular / cli

This is how i resolved it when i was installing and configuring angular on my ubuntu.

The problem is that , this solution is not working for everyone.

The best way to resolve EACCES permissions errors when installing packages globally is to install npm with node version manager or manually change npm’s default directory.

Let’s start with the easiest part of the Jobs

How to install NVM ( Node Version Manager )?

If you own an ubuntu or debian based distribution , execute these script . You dont need to change your current node js installation.

To install or update nvm, you should run the install script. To do that, you may either download and run the script manually, or use the following cURL or Wget command:

curl -o- | bash
wget -qO- | bash

Running either of the above commands downloads a script and runs it.

The script clones the nvm repository to ~/.nvm, and attempts to add the source lines from the snippet below to the correct profile file (~/.bash_profile~/.zshrc~/.profile, or ~/.bashrc).

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/" ] && \. "$NVM_DIR/" # This loads nvm

How to use NVM ?

nvm allows you to quickly install and use different versions of node via the command line.


$ nvm use 16
Now using node v16.9.1 (npm v7.21.1)
$ node -v
$ nvm use 14
Now using node v14.18.0 (npm v6.14.15)
$ node -v
$ nvm install 12
Now using node v12.22.6 (npm v6.14.5)
$ node -v

Simple as that!

If you don’t have linux or want to learn more about NVM , go to

Manually change npm’s default directory

These steps doesn’t work on Microsoft Windows.

To minimize the chance of permissions errors, you can configure npm to use a different directory. In this example, you will create and use hidden directory in your home directory.

  • Back up your computer.
  • On the command line, in your home directory, create a directory for global installations:
mkdir ~/.npm-global
  • Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
  • In your preferred text editor, open or create a ~/.profile file and add this line:
export PATH=~/.npm-global/bin:$PATH
  • On the command line, update your system variables:
source ~/.profile
  • To test your new configuration, install a package globally without using sudo:
npm install -g jshint
  • Instead of steps 3-5, you can use the corresponding ENV variable (e.g. if you don’t want to modify ~/.profile):

These steps are extract from

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

Leave a Comment