JAVASCRIPT

Node.js

A collection of useful Node.js resources.

HTTP Server

An easy way to get a Node.js http server up and running is by installing the http-server node module globally, npm install http-server -g. Here is an example using the -a option to specify an address to use. For more options, run http-server --help.

http-server -a localhost

http-server default is to use address 0.0.0.0 which is reachable by all IP addresses of the local machine’s network interface. Therefore, it may not be safe to run this address on a public network.

Node Version Manager (NVM)

nvm is a utility for installing and managing multiple versions of node.js.

If node and npm is already installed, you will want to uninstall it completely prior to installing nvm. This stackoverflow post may help with that.

If using Oh My ZSH!, you will need to install nvm as a custom plugin re. installing nvm with zsh.

Commonly used nvm commands
  • nvm install-latest-npm (upgrade npm to latest)
  • nvm install node (install latest node release)
  • nvm install 6.14.4 (install specfic node version)
  • nvm ls (list installed versions)
  • nvm ls-remote (list available node releases)
  • nvm use 6.14.4 (use specific node version)
comments powered by Disqus