Monthly Archives: September 2011

Node.js : Writing your first Hello World program

Download location for the Node.js?

http://nodejs.org/#download

For Microsoft family, you need to download “node.exe Windows executable”.

Writing your first hello world program with Node.js

After downloading the executable to a folder, follow the below steps for writing your first program with Node.js

  1. Copy/paste the below code to a file and save it as HelloWorld.js file

    // These are like using statement in C#

    var http = require(“http”);

    var url = require(“url”);

    // This creates the web server object.

    http.createServer(function(request, response) {

    response.writeHead(200, {“Content-Type”: “text/plain”});

    response.write(“Hello World”);

    response.end();

    // Specify the port number for listening.

    }).listen(81);

    //

    console.log(“Your web server started”);

    2) Assuming that you have saved your HelloWorld.js file and Node.exe under the folder C:\Node, open the command prompt and navigate to the path C:\Node. Now run the following command at the prompt:

Your web server should running now and you should be seeing the message “Your web server started”.

3)Now open your browser  and type in the following URL:

http://localhost:81

You should be seeing the response from your HelloWorld server.


Yay! You have just created your very first application with Node.js.  For more information about Node.js visit http://nodejs.org/


Error occurred in deployment step ‘Activate Features’: Invalid file name. The file name you specified could not be used. It may be the name of an existing file or directory, or you may not have permission to access the file.

Error occurred in deployment step ‘Activate Features’: Invalid file name.
The file name you specified could not be used.  It may be the name of an existing file or directory, or you may not have permission to access the file.

This error occurred during the deployment of List Definition from Visual Studio.

Fix:

List definition name should match the folder name. Check the picture below.