'Installing gulp in linux root but still getting gulp not found error

I want to install gulp in the root directory of CentOS 7 but for some reason, after installation, it still says:

gulp: command not found

My npm version is 8.1.2 and node version is 16.13.2. When I try to run gulp -v then I am returned with the gulp version as

CLI version: 2.3.0
Local version: 4.0.2

But When I try to run sudo gulp -v then I am returned with gulp: command not found while it does not happen with npm and node.

I have installed gulp with npm install gulp -g.

Summary:

I want to access gulp in the root directory by using sudo command. I have tried answers from After installation of Gulp: “no command 'gulp' found” and https://stackoverflow.com/a/45707907/5222115 But none of them helped.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source