What’s the magic path for npm when using sudo?

I remember I was able to use something like sudo ${which npm} run xxx when I needed root privilege to run npm. What is it?

Answer

With bash you can do

sudo "$(which npm)" run ...

# or

sudo "`which npm`" run ...

Attribution
Source : Link , Question Author : Aero Windwalker , Answer Author : joeytwiddle

Leave a Comment