xxx@CN_C02xxxxx6M ~ % npm install -g yarn 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/xxxxx/.npm/_logs/2022-12-06T11_15_27_852Z-debug-0.log
sudo npm i yarn -g
XXX@CN_CXXXMD6M ~ % npm list -g /usr/local/lib ├── @quasar/cli@1.3.2 ├── corepack@0.14.1 ├── npm@8.19.2 └── yarn@1.22.18
命令快照文件
全局命令所指文件
vim ~/.bash_profile
把下面内容粘贴到环境变量文件里,
export PATH=/usr/local/lib/node_modules/yarn/bin/:$PATH
保存.bash_profile的编辑,执行一下文件
source ~/.bash_profile
命令行重新打开,就可以使用yarn
yarn -v
mkdir ~/.npm-global npm config set prefix '~/.npm-global'
vim ~/.bash_profile
把下面内容粘贴到环境变量文件里,
export PATH=~/.npm-global/bin:$PATH
保存.bash_profile的编辑,执行一下文件
source ~/.bash_profile
命令行重新打开,就可以使用yarn
(如果未安装,可以打开终端,输入以下命令安装Homebrew)
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew --version
brew install yarn
欢迎大家指出文章需要改正之处~
学无止境,合作共赢