1 ---
2 title: Resolving EACCES permissions errors when installing packages globally
3 redirect_from:
4 - /getting-started/fixing-npm-permissions
5 ---
6
7 If you see an `EACCES` error when you try to [install a package globally][global-install], you can either:
8
9 - Reinstall npm with a node version manager (recommended),
10
11 **or**
12
13 - Manually change npm's default directory
14
15 ## Reinstall npm with a node version manager
16
17 This is the best way to avoid permissions issues. To reinstall npm with a node version manager, follow the steps in "[Downloading and installing Node.js and npm][install-npm]". You do not need to remove your current version of npm or Node.js before installing a node version manager.
18
19 ## Manually change npm's default directory
20
21 <Note>
22
23 **Note:** This section does not apply to Microsoft Windows.
24
25 </Note>
26
27 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.
28
29 1. Back up your computer.
30
31 2. On the command line, in your home directory, create a directory for global installations:
32
33 ```
34 mkdir -p ~/.npm-global/lib
35 ```
36
37 3. Configure npm to use the new directory path:
38
39 ```
40 npm config set prefix '~/.npm-global'
41 ```
42
43 4. In your preferred text editor, open or create a `~/.profile` file and add this line:
44
45 ```
46 export PATH=~/.npm-global/bin:$PATH
47 ```
48
49 5. On the command line, update your system variables:
50
51 ```
52 source ~/.profile
53 ```
54
55 6. To test your new configuration, install a package globally without using `sudo`:
56
57 ```
58 npm install -g jshint
59 ```
60
61 Instead of steps 3-5, you can use the corresponding ENV variable (e.g. if you don't want to modify `~/.profile`):
62
63 ```
64 NPM_CONFIG_PREFIX=~/.npm-global
65 ```
66
67 <Note>
68
69 **npx: an alternative to running global commands**
70
71 If you are using npm version 5.2 or greater, you may want to consider [npx](https://docs.npmjs.com/cli/commands/npx) as an alternative way to run global commands, especially if you only need a command occasionally. For more information, see [this article about npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b).
72
73 </Note>
74
75 [global-install]: downloading-and-installing-packages-globally
76 [install-npm]: downloading-and-installing-node-js-and-npm
77 [npx]: https://www.npmjs.com/package/npx
78 [npx-article]: https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b