If i try to run this command bash respond with not found error:
$ npm -v
-bash: npm: command not found
with sudo also:
$ sudo npm -v
sudo: npm: command not found
but works when I run first a "sudo su":
$ sudo su
# npm -v
6.10.3
Why this happens? how can I fix it to works with sudo command?
As @franzisk pointed out, this can be issue of the $PATH
for the npm.
Try to do echo $PATH
both as normal user and super user. Also run which npm
as superuser. If you see any difference (for example, path to npm is not in the normal user path) make changes to your PATH
variable accordingly.