Homebrew Node MAMP htdocs Permissions or Path?

I've installed Node via Homebrew. The node and node_modules files have been installed in the path

usr/local/bin

I can execute js files inside of the node folder but not from within

/Applications/MAMP/htdocs/project 

The following code appears as text When I run example1.js via MAMP htdocs -

var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hellold\n');
}).listen(1337, '127.0.0.1');
console.log('Serverning at http://127.0.0.1:1337/');

When I call the same code in example2.js via Terminal.

$node node/example2.js  

Result via Terminal

Serverning at http://127.0.0.1:1337/

-

Is it a case of permissions or an incorrect path? I've tried $echo PATH and the result was

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin