How to install nodejs on Xampp localhost

Been seeing a lot of how to's on how to install nodejs but nothing is at all clear.

So I ask...

Can someone provide a step by step installation guide for installing and using nodejs on a xampp server?


After searching (source), I have found, that it's easier to install Node.js directly (so, no need of XAMP/WAMP):

  1. Install http://nodejs.org/download/

  2. Create a test file (example) C:\myFolder\test.js and put this code in that file:

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');
  1. Open CMD (COMMAND PROMPT) and execute:

    node C:\myFolder\test.js

  2. Open this address in your browser: http://127.0.0.1:1337/


Now It's really easy to install and use Node.js even with Apache if you are using Xampp/Wamp etc. Because unlike old days, now Node.js org has created MSI installer for windows. Below are the steps to install Node.js with Apache. It is assumed that you have already installed xampp

Download windows installer of Node.js from it's site http://nodejs.org/ click on download. Hit the Node.js website and click the big green Install button. It'll detect your OS and give you the appropriate installer. If for some reason it doesn't, click the downloads button and grab the one you need. Run the installer. That's it, you have installed Node.js and, equally, NPM – Node Package Manager – which lets you add all kinds of great stuff to Node quickly and easily.

Note

Keep your Apache and Node ports different. Declare Node port other than 80 or 8080 while creating server in Node because these are the default ports of Apache.

May be these Notes may help someone in future.

1) When Node.js is installed Node and NPM become available globally. Means that you can create your site anywhere on your hard drive and with command prompt go to your directory like in Windows Command prompt

d:/NodeSite/node server.js

and now you can access it via

http://localhost:3000

because your server.js is running with node.

2) Similarly, you can install any Node Package like installing Memcached package or Library

d:/NodeSite/npm install memcached

"NodeSite" is a folder contain your project. You can see that node and npm have become globals.


XAMPP and a node.js is two different things, which do not need to work together, nor do they need each other.

XAMPP consists of Apache, MySQL, PHP and Perl.

Where node.js is just like PHP or Apache, so an application.

Node.js can be installed from the website, http://nodejs.org or via the terminal following these instructions:

https://github.com/joyent/node/wiki/Installation


It is possible to run NodeJS trough Apache/XAMPP. Great tutorial how to setup httpd.conf / vhosts.conf http://thatextramile.be/blog/2012/01/hosting-a-node-js-site-through-apache

<VirtualHost 109.74.199.47:80>
    ServerName thatextramile.be
    ServerAlias www.thatextramile.be

    ProxyRequests off

    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    <Location />
        ProxyPass http://localhost:3000/
        ProxyPassReverse http://localhost:3000/
    </Location>
</VirtualHost>

In the end it would be accessible trough port 80 thatextramile.be


I never gave a lot of answers on this site. Because most of the time I'm not an expert however. I had the same issue a while back.

1) You don't really need this XAMPP. Node will create its own http_server so I suggest you just forward calls from XAMPP to the Node app.

2) a good start would be: nodeguide.com/beginner.html

3) I work with PHPstorm which is very nice for Node.js development.

3a) Node.js plugin -> https://www.jetbrains.com/phpstorm/help/installing-updating-and-uninstalling-repository-plugins.html

3b) read this: http://blog.jetbrains.com/webstorm/2014/01/getting-started-with-node-js-in-webstorm/

3c) running: http://blog.jetbrains.com/webstorm/2014/02/running-and-debugging-node-js-application/ 3d) Test your app. You mighht also need this:

4) (MysQl db) https://codeforgeek.com/2015/01/nodejs-mysql-tutorial/