sudo npm command not found ubuntu

I had trouble when try to install less module for nodejs. First I try this:

npm install -g less

But got an error "sudo npm command not found". So I find a solution:

sudo $(which npm) install -g less

Comments