简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM