On Ubuntu (the supported Linux development environment) using sudo to install composer is not recommended.
Problem is the npm prefix which can get set to /usr/local to which the user doesn’t have write access. Issuing an npm config set prefix /home/[user]/ will solve the problem.
For example if username is “abcd” then try issuing following command:
npm config set prefix /home/abcd/
You may have an old version of Composer or one of the components installed. Try using npm ls -g –depth=0 to see if you have some composer code already installed, and if so remove it with npm uninstall -g composer- where might be cli, or playground etc. Then retry with the install -g command.