Mac mini (M1, 2020)
Monterey
Brownie v1.17.2
nodejs v16.13.4
I am learning solidity according to reference(https://www.youtube.com/watch?v=M576WGiDBdQ&t=25510s).
Node.JS install is fine
when I tried this
npm install --global yarn
the terminal give the error information
npm ERR! code EACCES npm ERR! syscall mkdir npm ERR! path /usr/local/lib/node_modules/yarn npm ERR! errno -13 npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/yarn' npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/yarn'] { npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'mkdir', npm ERR! path: '/usr/local/lib/node_modules/yarn' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It is likely you do not have the permissions to access this file as the current user npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm ERR! A complete log of this run can be found in: npm ERR! /Users/liwei/.npm/_logs/2022-01-08T12_13_37_765Z-debug.log (base) liwei@liweideMac-mini-2 com~apple~CloudDocs %
I checked the owner of the file ,the owner is root ,should i use sudo?
(base) liwei@liweideMac-mini-2 com~apple~CloudDocs % ls -l /usr/local/lib/node_modules/npm total 64 -rw-r--r-- 1 root wheel 9742 10 14 08:49 LICENSE -rw-r--r-- 1 root wheel 4190 10 19 06:36 README.md drwxr-xr-x 9 root wheel 288 12 1 19:46 bin drwxr-xr-x 4 root wheel 128 12 1 19:46 docs -rw-r--r-- 1 root wheel 145 11 23 14:00 index.js drwxr-xr-x 77 root wheel 2464 12 1 19:46 lib drwxr-xr-x 5 root wheel 160 12 1 19:46 man drwxr-xr-x 188 root wheel 6016 12 1 19:46 node_modules -rw-r--r-- 1 root wheel 6007 12 1 19:13 package.json drwxr-xr-x 3 root wheel 96 12 1 19:46 tap-snapshots (base) liwei@liweideMac-mini-2 com~apple~CloudDocs %
find this thread (Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’),changed the owner , stll one file don’t change.
(base) liwei@liweideMac-mini-2 com~apple~CloudDocs % sudo chown -R liwei: /usr/local/lib/node_modules (base) liwei@liweideMac-mini-2 com~apple~CloudDocs % ls -la /usr/local/lib/node_modules total 0 drwxr-xr-x 4 liwei wheel 128 1 8 11:51 . drwxr-xr-x 4 root wheel 128 1 8 11:51 .. drwxr-xr-x 7 liwei wheel 224 12 1 19:46 corepack drwxr-xr-x 13 liwei wheel 416 12 1 19:46 npm
what is this 2 dots is?
Advertisement
Answer
reference answer is here (Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’)
This works for me very quick.
To minimize the chance of permissions errors, you can configure npm to use a different directory. In this example, you will create and use a 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