2019-08-16 14:48:06 -05:00
|
|
|
|
# NPM
|
|
|
|
|
|
|
|
|
|
## Resolving EACCES permissions errors when installing packages globally
|
2019-08-16 14:45:36 -05:00
|
|
|
|
|
2019-09-12 22:01:19 -05:00
|
|
|
|
1. On the command line, in your home directory, create a directory for global installations:
|
2019-08-16 14:45:36 -05:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
mkdir ~/.npm-global
|
|
|
|
|
```
|
|
|
|
|
|
2019-09-12 22:01:19 -05:00
|
|
|
|
2. Configure npm to use the new directory path:
|
2019-08-16 14:45:36 -05:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
npm config set prefix '~/.npm-global'
|
|
|
|
|
```
|
|
|
|
|
|
2019-09-12 22:01:19 -05:00
|
|
|
|
3. In your preferred text editor, open or create a `~/.profile` file and add this line:
|
2019-08-16 14:45:36 -05:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
export PATH=~/.npm-global/bin:$PATH
|
|
|
|
|
```
|
|
|
|
|
|
2019-09-12 22:01:19 -05:00
|
|
|
|
4. On the command line, update your system variables:
|
2019-08-16 14:45:36 -05:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
source ~/.profile
|
|
|
|
|
```
|
|
|
|
|
|
2019-09-12 22:01:19 -05:00
|
|
|
|
5. To test your new configuration, install a package globally without using `sudo`:
|
2019-08-16 14:45:36 -05:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
npm install -g jshint
|
|
|
|
|
```
|