NodeJS Commands
Running Node from the Command Line
$ node hello.js [Providing the js extension explicitly.]
$ node hello [Extension js assumed.]
Starting Node
$ node [To get to the command prompt.]
$ node start [To start a project from the package.json file.]
Exiting from the Node REPL
> .exit
> CTRL+C CTRL+C
Using Node as a calculator (just because you can)
> 2 + 3
> n = 7
> n * 5
Exploring after starting Node
> console.log("Hello, Node.js!") [Display the string on the screen.]
> .help [Print a help message showing some "dot commands".]
> .load file.js [Load JS from a file into the REPL session.]
> .break [Sometimes you get stuck, this gets you out.]
> .clear [Alias for .break.]
> .editor [Enter editor mode.]
> .save [Save all evaluated commands in this REPL session to a file.]
Running npm (node package manager) from the command line
$ npm -v [Display current version of node package manager.]
$ npm config list [Manage npm configuration files.]
$ npm config ls -l [List all defaults.]
$ npm install module_name
[Installs module_name locally in node_modules.]
$ npm install module_name --global [or -g]
[Installs module_name globally in {prefix}node_modules.]
[{prefix}node_modules must be set in npm's configuration.]
$ npm uninstall module_name {-g if global]
$ npm update module_name {-g if global]
> npm config get prefix [Typically might be /usr/local]
> npm list [Lists all (local) packages in a project.]
> npm list -g [Lists all (including global) packages in a project.]
> npm list -g -depth=0 [List does not include dependencies.]
> npm list module [Checks if a specific module is installed locally.]
> npm list -g module [Checks if a module is installed globally.]
Node documentation
> npm docs underscore
> npm bugs underscore
> npm edit underscore [Only from project root on downloaded modues.]