Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

NodeJS and MAMP running on local machine. Is it possible?

NodeJS and MAMP running on local machine. Is it possible?

Problem

Is it possible to have Nodejs and Mamp Running together on the same machine? If so how would i achieve this?

Note: I can run them separately just not together. I assume its down to my NodeJS using the "localhost" as well as Mamp.

Problem courtesy of: ChrisMJ

Solution

This depends on what you want NodeJs to do?

Are you using NodeJS to work as a webserver?

You could set it to run on another port number - this would let you access it through:

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/');

Then visit http://localhost:1337

Solution courtesy of: Mark Willis

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

NodeJS and MAMP running on local machine. Is it possible?

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×