First check the versions of node and npm by the following commands..
Now lets say your workspace is in d:/workspace
here you need to create a basic site with nodejs and express..
In order to do that, first install express in your machine globally..
you can achieve this by following commands
npm install -g express - old process
D:\workspace>npm install -g express-generator (preferable)
With this you can see a list of folders will be created like shown below
You’ll note that the express installation routine created a file called package.json in your nodetest directory. Open this up in a text editor and it’ll look like this:
This is a basic JSON file describing our app and its dependencies. We need to add a few things to it. Specifically, calls for MongoDB and Monk. Let’s make our dependencies object look like this:
Now we’ve defined our dependencies and we’re ready to go. Note that the asterisks tell NPM “just get the latest version” when you run the install, which we’re about to do.
Return to your command prompt, cd to your nodetest directory, and type this:
It’s going to print out a ton of stuff. That’s because it’s reading the JSON file we just edited and installing all the stuff listed in the dependencies object (yes, including Express – we installed the top level stuff using the –g flag, but we still have to install some necessary code for this particular project). Once NPM has run its course, you should have a node_modules directory which contains all of our dependencies for this tutorial.
You now have a fully-functioning app ready and waiting to run. Before we do that, though, we need to do one quick thing to prepare for setting up our database later. Still in your nodetest1 directory, type this:
That’s where we’re eventually going to store our MongoDB data. If that directory doesn’t exist, the database server will choke when we go to run it later. We’re not doing anything with it right now, though, so let’s test out our web server! Type the following:
Hit enter. You’ll get this:
Everything working? Awesome! Open a browser and head for http://localhost:3000 where you will see a welcome to Express page.
You are now running your own Node JS webserver, with the Express engine and Jade HTML preprocessor installed 🙂