Installing node.js in Virtual Machine.
After running the virtual machine, ssh to it.
Anyway I have just installed the latest version.
First we need to install the NVM.
So take the terminal and follow the steps in the below link.
https://www.liquidweb.com/kb/how-to-install-nvm-node-version-manager-for-node-js-on-ubuntu-12-04-lts/
so after installing nvm we can install the desired node js version
I have installed the latest version by using the below command
nvm install node
for more info about installing node check the below link:
https://www.sitepoint.com/quick-tip-multiple-versions-node-nvm/
After restarting the terminal if you see any error when running the command 'node' from the terminal like the following :
"The program 'node' can be found in the following packages:
* node
* nodejs
Try: apt-get install <selected package>"
then use the command : nvm use node
As I am using Virtual machine I need to update the server code slightly to get the node run in the main browser that is not in virtual machine
I have created the server using the below code.. check the listen section, where I put the IP address of the virtual machine.
var http = require("http");
http.createServer(function (request, response) {
// Send the HTTP header
// HTTP Status: 200 : OK
// Content Type: text/plain
response.writeHead(200, {'Content-Type': 'text/plain'});
// Send the response body as "Hello World"
response.end('Hello World\n');
}).listen(8081, '192.168.56.102');
// Console will print the message
console.log('Server running at http://192.168.56.102:8081/');
Now you can start develop your own code..
No comments:
Post a Comment