I believe the previous answer is the correct answer to this problem but I was getting this error when I tried installing npm package (see below) :
The fix for me was : npm init --yes
npm init --yes
Tilde expansion is a shell thing. Write the proper pathname (probably /home/yourusername/Desktop/etcetcetc) or useprocess.env.HOME + '/Desktop/blahblahblah'
/home/
/Desktop/etcetcetc
process.env.HOME + '/Desktop/blahblahblah'
npm install
npm cache clean
npm install -g npm
ng serve --o