You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: improve documentation on resolving EACCES (#1711)
Simplify the steps a bit:
- Backing up the computer and creating the directory is not necessary,
since it's created automatically by npm.
- Use the ~/.local directory which is the standard place for
user-specific software, and likely to already be in the user's PATH.
- `export` is not needed since PATH is already exported.
- Add a note for zsh which doesn't use ~/.profile.
- Use a different package as an example, since jshint is not regularly
updated, and linters should generally be in `devDependencies` and used
through npm scripts.
- Ensure the user can run the installed tool.
- Remove mention of `NPM_CONFIG_PREFIX` which is not sufficient, since
the PATH still needs to be updated to use global tools.
Copy file name to clipboardExpand all lines: content/packages-and-modules/getting-packages-from-the-registry/resolving-eacces-permissions-errors-when-installing-packages-globally.mdx
+14-16Lines changed: 14 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,45 +24,43 @@ This is the best way to avoid permissions issues. To reinstall npm with a node v
24
24
25
25
</Note>
26
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.
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 a hidden directory in your home directory.
28
28
29
-
1. Back up your computer.
30
-
31
-
2. On the command line, in your home directory, create a directory for global installations:
29
+
1. Configure npm to use the new directory path:
32
30
33
31
```
34
-
mkdir -p ~/.npm-global/lib
32
+
npm config set prefix ~/.local
35
33
```
36
34
37
-
3. Configure npm to use the new directory path:
35
+
2. In your preferred text editor, open or create a `~/.profile` file and add this line:
38
36
39
37
```
40
-
npm config set prefix ~/.npm-global
38
+
PATH=~/.local/bin:$PATH
41
39
```
42
40
43
-
4. In your preferred text editor, open or create a `~/.profile` file and add this line:
41
+
If you are using zsh (which you can find out by running `echo $0`), you will also need to add this line to `~/.zprofile`:
44
42
45
43
```
46
-
export PATH=~/.npm-global/bin:$PATH
44
+
source ~/.profile
47
45
```
48
46
49
-
5. On the command line, update your system variables:
47
+
3. On the command line, update your system variables:
50
48
51
49
```
52
50
source ~/.profile
53
51
```
54
52
55
-
6. To test your new configuration, install a package globally without using `sudo`:
53
+
4. To test your new configuration, install a package globally without using `sudo`:
56
54
57
55
```
58
-
npm install -g jshint
56
+
npm install -g npm-check-updates
59
57
```
60
58
61
-
Instead of steps 3-5, you can use the corresponding ENV variable (e.g. if you don't want to modify `~/.profile`):
0 commit comments