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
Tilde expansion is a shell thing. Write the proper pathname (probably /home/yourusername/Desktop/etcetcetc) or use
process.env.HOME + ‘/Desktop/blahblahblah’