Skip to content

Fix npm permission errors when installing packages globally on macOS

Notifications You must be signed in to change notification settings

htpwebdesign/fix-npm-permission-errors-on-mac-os

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 

Repository files navigation

Fix npm Permission Errors and Gulp Install Errors on macOS

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

Instructions

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.

  1. Open your macOS Terminal application
  2. Navigate to your home directory from within the terminal by typing the following command and pressing “Enter”
$ cd~
  1. Inside your home directory create a directory for global npm installations by entering the following command
$ mkdir ~/.npm-global
  1. Configure npm to use the new directory
$ npm config set prefix '~/.npm-global'
  1. 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"

  1. 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
  1. Save the file and close the text editor application

  2. Return to the terminal and update your system variables by entering the following command

$ source ~/.profile
  1. Change the npm install directory
$ npm config set prefix /usr/local
  1. Install Gulp globally
npm install gulp -g
  1. Try Gulp form the terminal (you should get a version number outputted to the terminal)
$ gulp --version
  1. 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

About

Fix npm permission errors when installing packages globally on macOS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published