NPM global packages not available on Ubuntu

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?


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.

链接地址: http://www.djcxy.com/p/27700.html

上一篇: Java 8中的map和flatMap方法有什么区别?

下一篇: NPM全局软件包在Ubuntu上不可用