NPM global packages not available on Ubuntu

4.2k Views Asked by At

MY SITUATION

I have installed version Node v6.2.0 using n on Ubuntu 14.04. It's located under path /usr/local/n/versions/node/6.2.0 (by using npm prefix -g).

My global packages installs in that directory under lib/node_modules but I can't use that packages from command line globally.

NOTE Earlier I was using older version Nodejs 5 installed different way. And packages installed globally with that version of Node are available now, but not new ones which I installing now.

MY QUESTION

Is there a trick or something to point node_modules directory from which its packages could be used globally?

2

There are 2 best solutions below

6
On BEST ANSWER

Your global package binaries should be available here:

/usr/local/n/versions/node/{NODE VERSION}/bin

Add it to your path (in .bashrc or .bashprofile or .zshrc):

NPM_GLOBALS=/usr/local/n/versions/node/{NODE VERSION}/bin
PATH=$NPM_GLOBALS:$PATH

Then restart your console or just run source ~/.bashrc

Also, if you're working with multiple versions of node, I highly recommend nvm for installing and managing them.

0
On

I simply added export PATH=~/.npm-global/bin:$PATH to my .zshrc file.