====== H) Using npm on Gentoo ====== Quite similarly to the issue with [[gentoo:pip|pip]], direct installation of NodeJS packages via **npm** poses some issues since you don't really want to mess up your system by installing out of tree packages. Everything //should// be managed by portage, but hey, there are literally thousand of packages that you might find usefull to install via **npm**. The solution is simple. First of all, ensure that you have **net-libs/nodejs** installed with the //npm// use flag: echo "net-libs/nodejs npm" >> /etc/portage/package.use/nodejs emerge -v net-libs/nodejs this will ensure you have the **npm** command available, but you __do not__ want to run it as user //root//, instead the best practice is to install packages only as non-root users. To do so, you need to run, as the non-root user, the following command: su - my_non_root_user npm config set prefix .npm_install Add this to your **~/.bashrc**: export PATH=$PATH:~/.npm_install/bin At this point, you will be able to install packages with a command like: npm install mypackage -g And it will work!