diff --git a/content/packages-and-modules/getting-packages-from-the-registry/resolving-eacces-permissions-errors-when-installing-packages-globally.mdx b/content/packages-and-modules/getting-packages-from-the-registry/resolving-eacces-permissions-errors-when-installing-packages-globally.mdx index f7b0c9ebe4b..cd365747aa3 100644 --- a/content/packages-and-modules/getting-packages-from-the-registry/resolving-eacces-permissions-errors-when-installing-packages-globally.mdx +++ b/content/packages-and-modules/getting-packages-from-the-registry/resolving-eacces-permissions-errors-when-installing-packages-globally.mdx @@ -24,45 +24,43 @@ This is the best way to avoid permissions issues. To reinstall npm with a node v -To minimize the chance of permissions errors, you can configure npm to use a different directory. In this example, you will create and use hidden directory in your home directory. +To minimize the chance of permissions 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. Back up your computer. - -2. On the command line, in your home directory, create a directory for global installations: +1. Configure npm to use the new directory path: ``` - mkdir -p ~/.npm-global/lib + npm config set prefix ~/.local ``` -3. Configure npm to use the new directory path: +2. In your preferred text editor, open or create a `~/.profile` file and add this line: ``` - npm config set prefix ~/.npm-global + PATH=~/.local/bin:$PATH ``` -4. In your preferred text editor, open or create a `~/.profile` file and add this line: + If you are using zsh (which you can find out by running `echo $0`), you will also need to add this line to `~/.zprofile`: ``` - export PATH=~/.npm-global/bin:$PATH + source ~/.profile ``` -5. On the command line, update your system variables: +3. On the command line, update your system variables: ``` source ~/.profile ``` -6. To test your new configuration, install a package globally without using `sudo`: +4. To test your new configuration, install a package globally without using `sudo`: ``` - npm install -g jshint + npm install -g npm-check-updates ``` -Instead of steps 3-5, you can use the corresponding ENV variable (e.g. if you don't want to modify `~/.profile`): + And run it: -``` -NPM_CONFIG_PREFIX=~/.npm-global -``` + ``` + ncu -g + ```