document-dump/linux-npm-eacces-errors.md

34 lines
704 B
Markdown
Raw Normal View History

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
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
```
2. Configure npm to use the new directory path:
2019-08-16 14:45:36 -05:00
```
npm config set prefix '~/.npm-global'
```
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
```
4. On the command line, update your system variables:
2019-08-16 14:45:36 -05:00
```
source ~/.profile
```
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
```