Node.js -1 | Initialize a Node.js project with dependencies

Not so long ago I’ve started to study lessons about Node.js. There’s no need to praise or to talk about it or why I want to learn it, it just excites me as a new platform and I intend to keep studying unless I don’t feel like it’s not worth it -which I doubt.

Here I want to share my Node.js notes regularly, from very basic to the complex(hopefully).


Running Node.js scripts

Download and install from:

To build (run) a Node.js script:

> node file.js


Initializing a node app and build it with dependencies

1- Initialize:

> npm init

2- After initialization, package.json contains project information. You can add “dependencies” to this file like:

"dependencies": {
	"node-markdown": "0.1.0"

If you want to require latest version of a dependency module:

"node-markdown": "*"

3- Install these dependencies:

> npm install


Some other useful stuff about managing the app

Update these dependencies to latest versions:

> npm update

Update node.js global libraries:

> npm update -g

Remove an installed library:

# remove from "dependencies" object in package.json, then:
> npm prune

Search through node.js modules available for free:

> npm search 
# better not to use it without grep or it may take quite long time
> npm search | grep markdown
# or find from

Tail changes of a file and execute it automatically on console after each change:

# -g installs as global
> sudo npm install node-dev -g
> node-dev script.js


No “Hello, world!” yet. These are just basics that we’ll probably do quite seldom.