These instructions have been modified from instructions found here:
Resolving Eacces Permissions Errors when Installing Packages Globally
and here: Stackoverflow Question: Gulp Command Not Found after Install
These instructions are only necessary for macOS users. These instructions do not apply for Windows users
To minimize the chance of permission errors, you can configure npm to use a different directory. In this example, you will create and use a hidden directory in your home directory.
- Open your macOS Terminal application
- Navigate to your home directory from within the terminal by typing the following command and pressing “Enter”
$ cd~
- Inside your home directory create a directory for global npm installations by entering the following command
$ mkdir ~/.npm-global
- Configure npm to use the new directory
$ npm config set prefix '~/.npm-global'
- Open the “.profile” file from the command line
$ open ~/.profile
NOTE: If you get the "profile does not exist error then do the following:
$ touch ~/.profile
Press "Enter"
$ open ~/.profile
Press "Enter"
- The “.profile” file will probably open in the “textEdit” application. If not, it will open in whatever default text editor you have setup with Terminal. With the “.profile” file open in a plain text editor add the following line to the end of the file (or the first line if the file is blank)
$ export PATH=~/.npm-global/bin:$PATH
-
Save the file and close the text editor application
-
Return to the terminal and update your system variables by entering the following command
$ source ~/.profile
- Change the npm install directory
$ npm config set prefix /usr/local
- Install Gulp globally
npm install gulp -g
- Try Gulp form the terminal (you should get a version number outputted to the terminal)
$ gulp --version
- Optional If step 11 & 12 did get the desired output, then try installing gulp using the "sudo" command. When the terminal asks for your password, use the password for your computer and press the "retur" key