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

created at 07-10-2021 views: 32

error description

When Mac used npm to install the package npm i -g xxxx, it reported an error: 

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


It can be seen from the error message that our operation lacks authority, and we can prescribe the right medicine, so we only need to give the administrator authority when executing the command.

Add sudo in front of the command line to get administrator privileges, just enter the administrator password.

That is, change 

npm i -g xxxx 


sudo npm i -g xxxx 

and then enter the password.

created at:07-10-2021
edited at: 07-10-2021: