Adding npm bin/ path to command search path


npm installs packages by default under node_modules/ within the current working directory. Binary files, if bundled with a package, are installed under node_modules/.bin/ unless the global (-g) flag is supplied to npm install. This works if only a single version of a particular package is installed, but fails in most multi-version setups.


Add node_modules/.bin/ to your search path, called “PATH". PATH is a special environment variable in bash that defines the order of directories a file is searched for when executing a command.

Simply run this command from the terminal, making note of the single-quote (‘) and double-chevron (>>) usage:

echo 'PATH=$PATH:./node_modules/.bin:../node_modules/.bin' >> ~/.bash_profile

Log out of the terminal and log back in.

Notes: it is acceptable to omit ../node_modules/.bin from the path. This is used for situations like Sails that create a separate directory for its application.

See also

Leave a Reply