I am trying to install SailsJS with:
$ sudo npm install -g sails
It works, install everything at /home/brunoluiz/npm/lib/node_modules/sails
In addition to mklement0's answer, the first solution (adding the npm binary directory path to the PATH variable) creates another problem when the commands are run with sudo
prefix on Linux environment. To solve it, the npm binary directory path must also be added in secure_path
in /etc/sudoers.tmp
. Here is how:
Why can't sudo find a command after I added it to PATH?
It sounds like your npm
installation is configured to use /home/brunoluiz/npm
as prefix
, meaning that it will place symlinks to the CLIs that come with globally installed packages in {prefix}/bin
.
In a default installation, prefix
is either /usr
or /usr/local
on Unix platforms (%APPDATA%/npm
on Windows).
If {prefix}/bin
is not in your $PATH
, you won't be able to execute such CLIs just by name.
To see the current prefix
value in effect, run:
npm get prefix
Your options are:
Add /home/brunoluiz/npm/bin
to your $PATH
Change the value of the prefix
configuration item to a folder whose bin
subfolder is already in your $PATH
; e.g.:
npm set prefix /usr # Ubuntu; CLI symlinks are placed in /usr/bin
npm set prefix /usr/local # OSX; CLIs symlinks are placed in /usr/local/bin
Note, however, that you'd then have to reinstall your global packages for the symlinks to be created in the new {prefix}\bin
location.