Some help getting node.js running?

I’m new to node.js, and as an exercise am trying to get it set up on one of my domains on my Dreamhost shared server account. I followed the instructions here and believe I have things installed correctly. Some tests:

$ node --version
v12.18.3
$ nvm --version
0.35.3
$ npm --version
6.14.6
$ which node
/home/[myusername]/.nvm/versions/node/v12.18.3/bin/node
$ /home/[myusername]/.nvm/versions/node/v12.18.3/bin/node --version
v12.18.3

The contents of my .htaccess file in the root of my domain:

# turns on passenger 
PassengerNodejs /home/[myusername]/.nvm/versions/node/v12.18.3/bin/node

# enable "friendly" error messages (print errors in browser)
PassengerFriendlyErrorPages on

One of the things I’m confused about is how to deploy my app.js. I know I put it in the root of my domain, but do I have to run it?

Currently this is the contents of my app.js:

var http = require("http");

http.createServer(function(request, response) {
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.write("Hello World. This page is running Node.js version: ");
  response.write(process.version);
  response.end();
}).listen(80);

But when I visit my domain I get the following error:

{"errno":-21,"code":"EISDIR","syscall":"read"}

Does anyone have any idea why?

My theory is I don’t actually have to serve (createServer) my application? Am I on the right track?

Thanks for any help.

1 Like

The error code suggests there is trouble reading a directory for some reason.

Check out this thread to see if it helps you get a simple server running: