small typo at https://docs.npmjs.com/getting-started/fixing-npm-permissions#option-two-change-npms-default-directory


(Erik Erikson) #1

The following statement appears to reference the wrong steps (i.e. 2-4):

Instead of steps 2-4, you can use the corresponding ENV variable (e.g. if you don’t want to modify ~/.profile)

That should maybe be 3-5?

The steps it is referencing come from https://docs.npmjs.com/getting-started/fixing-npm-permissions#option-two-change-npms-default-directory:

To minimize the chance of permissions errors, you can configure npm to use a different directory. In this example, it will be a hidden directory on your home folder.

  1. Back-up your computer before you start.
  2. Make a directory for global installations:
    mkdir ~/.npm-global
  3. Configure npm to use the new directory path:
    npm config set prefix ‘~/.npm-global’
  4. Open or create a ~/.profile file and add this line:
    export PATH=~/.npm-global/bin:$PATH
  5. Back on the command line, update your system variables:
    source ~/.profile

Test: Download a package globally without using sudo .
npm install -g jshint

Instead of steps 2-4, you can use the corresponding ENV variable (e.g. if you don’t want to modify ~/.profile ):
NPM_CONFIG_PREFIX=~/.npm-global