具体错误
tsit@ubuntu:/usr$ sudo npm install -g yarn npm WARN lifecycle yarn@1.22.19~preinstall: cannot run in wd %s %s (wd=%s) yarn@1.22.19 :; (node ./preinstall.js > /dev/null 2>&1 || true) /usr/local/lib/node_modules/.staging/yarn-53412bb0
解决办法
加上--unsafe-perm
sudo npm install --unsafe-perm -g yarn > yarn@1.22.19 preinstall /usr/local/lib/node_modules/.staging/yarn-53412bb0 > :; (node ./preinstall.js > /dev/null 2>&1 || true) /usr/local/bin/yarn -> /usr/local/lib/node_modules/yarn/bin/yarn.js /usr/local/bin/yarnpkg -> /usr/local/lib/node_modules/yarn/bin/yarn.js /usr/local/lib └── yarn@1.22.19