April 29, 2017
November 25, 2019
How to install NPM package in a home directory (PyCharm)
I don't like to install things as a root user. If it's possible to install something in my home directory, why not use it?
First, we need to tell NPM that it should install everything in
npm config set prefix '~/.npm'
Now every time when you install NPM package using
-g option it will
install it in
~/.npm directory. You don't need the root access to do it.
All executables will be in
~/.npm/bin directory. For example if I install
npm install -g eslint command then it will be possible to
eslint command from terminal using full path:
It's inconvenient, right? It's better to be able to use just
command. To achieve that we need to modify
Find in this file line which starts with
PATH= and add
at the end of the line. In my
~/.bash_profile file it looks like this:
If the line with
PATH doesn't exist then you can add it:
Now you need to apply changes.
And it's done. You should be able to run
eslint without specifying the full
path to the file.
Quick tip about PyCharm. PyCharm needs a full path to the ESLint directory,
not to ESLint executable file. In settings you need to use