The issue more likely than not, has to do with the OS implementation - see node.js - NPM modules won't install globally without sudo - Stack Overflow.
On Debian and Ubuntu the package manager appears to cause problems if yarn installed from standard repository.
See the install instructions - Guide: Manual Install ERPNext on Ubuntu 17.xx & 18.xx
The package must be installed globally and a non-sudo user must be able to run scripts.
I.e. see Resolving EACCES permissions errors when installing packages globally | npm Docs
npm config set prefix '~/.npm'
export PATH=~/.npm/bin:$PATH
source ~/.profile
to test without sudo …
npm install -g jshint
Assuming path at
/opt/bench/erpnext
Also do
npm install -g yarn
bench update --requirements
bench setup socketio
bench build
Without using sudo
Then do
bench update --reset