nodejs

I want to use sudo-free node with Hexo and blockchain related scripts. Do not use the apt-get method of installation on Debian as that provides a “nodejs” executable rather than “node” which can be problematic (at least with Hexo). I will follow the installation instructions at nearform. There is also a good tutorial at sitepoint.

Determine if node is installed:

1
2
$which node
$which npm

and remove if it is:

1
2
3
4
sudo rm -f /usr/local/share/man/man1/node.1
sudo rm -f /usr/local/lib/dtrace/node.d
sudo rm -rf ~/.npm
sudo rm -rf ~/.node-gyp

Install using NVM

1
2
3
4
5
#apt-get install curl  ;;if needed
$curl https://raw.githubusercontent.com/creationix/nvm/v0.25.0/install.sh | bash
$nvm install stable ;;; or choose a particular version
## restart terminal
$nvm alias default stable ;; set stable as the default

;;to see where executable reside

1
npm config get prefix

use ~/.npm for local (global) installation
always install with the -g option (global, but with my setup it will be under my home dir, no sudo needed)
the -save option adds the package to the application specific package list, so it will automatically be installed when the package is moved.

Share