I am new to using nodejs completely, and it seems to be pretty much the go to thing for everything right now. But I program in Visual Studio, and I'm a bit confused about how this works. I will cite an example;

One task I want to do is to get a list of all the files in a directory and all of its sub-directories, and return them as a string[] for a javascript .config file. I started searching for that and found a lot of answers, but they all kept going back to nodejs, for instance, this one, and this one, and this one.

I really wasn't looking for anything having to do with nodejs, it just seems to be part of every solution out there. I've installed it, and gotten it to where I can do some simple things like create a very basic server that listens to a port - thanks to simple tutorials written for a moron like me - but I'm having a hard time figuring out how to use these kinds of things in my real programs - specifically ASP.NET MVC. I've searched pretty hard on this topic too, and discovered things like iisnode and the like that do some partial integration.

But even with all of this, this wealth of information, I am extremely confused.

I understand that I can use it from a command line, like PowerShell, I can run commands from a terminal, and install packages into projects, but I'm having a hard time seeing and finding how this actually translates into literal, real usage in an existing application. I have scoured around for days and days for examples, I've read at least 3 books on nodejs, The Node Beginner Book, What is Node, and Professional Node.js and to be very honest I am still as lost as ever.

Everything I read keeps assuming I am doing things from the command line or a terminal, but all of the applications I see for node assume you're writing a web application. I'm having a really hard time wrapping my head around how you use it within an application. Can anyone assist me with this? Perhaps a working example of an actual program that uses node? I'll take almost anything at this point, though ASP.NET MVC is my core system of choice.

I was originally going to post this on StackOverflow, but someone suggested that this community was more appropriate for this question.


I want to make a more clear example of what is confusing me, I'm already learning because of the 1 proposed answer, but let me give more examples.

I program in Visual Studio, it has no real concept of node.js - in fact, if I try to do things that will run against node, it gives me problems. I often have to code anything related to node in WebStorm from JetBrains.

I understand that I can 'compile' things with node, what I don't understand is how I can invoke it within my program, not inside of a command line. For example let's say there is a node module that takes an array and does something to it - for sake of example let's say that it sorts everything in the array alphabetically, and it is a module called supersort.

So if I were at the console, I would just type in ...

node supersort.js

Okay, but now I'm not at the command line. I have published my web application. My user is at a page, let's say /account/history and they are seeing a list of every product they have bought. For the sake of argument, say I've got that list as a object[] or string[] - I realize that is completely absurd and it would be far more complex, but just jive with me.

I want to run supersort on this page. But it's live! How do I do it? How do I run this module on their live, active data without manually being there at the console? Is there a set of javascript files I'm supposed to download and call http requests a certain way? Do I wire up a special IHttpHandler in IIS? I think you can start to see where I am lost.

Update 2

Attempting to further emphasize my question, I'll try and cite a more specific example. I want to use the library Q.js in my ASP.NET MVC application. Now, there is a version 1 that I can seem to run out of the box, but I want to try out version 2 - you can find it linked Q.js v2 (beta)

So I am using Visual Studio, and I'll download the q.js file and load it up, but immediately we already have trouble now - if you look at the file's source code right away I see this.

var WeakMap = require("collections/weak-map");
var Iterator = require("collections/iterator");
var asap = require("asap");

Now I certainly don't have folders with those names in my application - and even though I have node.js installed, putting this file in a <script> tag does not work, as it says it cannot find the specific libraries. If I go to a console explicitly and type in npm install -g q@~2, it will create a folder called node_modules/q in my AppData/Roaming/npm folder, and this one does have folders for those other libraries.

So what is the right way to do this? It's clear that just having node installed doesn't make node commands work when I try to run the page in ASP.NET MVC - but I also don't understand how to get to the final version of the library that I can include on my application like a normal javascript file and use across the program.

2 Answers 2


node.js (not nodejs, as you seem to put it), is a server side technology.

In that respect, it is like Apache or IIS - web servers.

It can and mostly is used as a backend for web applications (and web based APIs) - it serves up whatever it is coded to serve up (in that respect, no different from Apache and IIS).

If you code up a web application (serving HTML and whatever else is involved in writing a web application) in node, that's what it would be serving, a web application.

The reason you see a lot of discussion of the command line/terminal is that there is no GUI for node. One is expected to use an editor to write the node application and run it from the command line. It is not wrapped up in a service for you, like IIS.

  • So essentially, it's no different than running csc [filename].cs and pulling a file through the C# compiler? It's simply intended to be compiled and then the output hosted in any other manner?
    – Ciel
    Commented Jun 28, 2014 at 14:30
  • Hey @Oded, I updated my question with a more verbose example. The fact that you're not shooting me down outright means I'm at least asking a question to the right audience, I feel. Believe it or not, your small little text answered more than all three of those books I read already.
    – Ciel
    Commented Jun 28, 2014 at 14:44
  • Regarding your update - in short, you don't invoke node from the command line from your application. You have it already running in its own process (as a server) and have your application communicate with that.
    – Oded
    Commented Jun 28, 2014 at 16:22
  • Hey @Oded, I have updated again to try and be more specific about what is causing me trouble. I understand a bit of what you're saying, but I'm still having a tough time getting over the way to implement this.
    – Ciel
    Commented Jun 29, 2014 at 18:18
  • @Ciel - I am afraid I can't help with your update 2, not being a node developer. It would appear that the library you are using (Q.js) has some assumptions and dependencies - perhaps the project page details them, or you can look for these by name.
    – Oded
    Commented Jun 29, 2014 at 18:25

It seems to me that you've gone down a rabbit hole. If you're writing an application in ASP.Net, why not just research how to solve a particular problem in that platform? I'd need to have a pretty damn good reason to add another tool/language/platform to my solution, and I don't get the impression that such a compelling reason exists for you. Node.js may be the hip thing right now and offer some pretty neat ways to solve problems, but you probably could have solved your problem natively 10 times over by now. That's just my two cents.

  • I don't necessarily think you are wrong, as you are accurate in saying it is an un-needed stress that just adds to my work load. However I continuously keep running into JavaScript libraries I want to use, and many of them seem to require node.js. While I inevitably may not need, or even use it - I think that there is merit in at least understanding it so I can be prepared for more things.
    – Ciel
    Commented Jul 7, 2014 at 12:28
  • To quote myself 12 years ago, "I didn't learn JavaScript because it's not really needed.", I'm not going to make that mistake again.
    – Ciel
    Commented Jul 7, 2014 at 12:44
  • Oh, I totally agree. I've been dabbling with node.js off and on over the last few years as well. It's probably a good thing to get familiar with. I just think you're likely to get a bad taste in your mouth about it by going down this path. If you're keen to learn javascript in general, you may be better served by using something like jQuery on your ASP.net pages. That seems like a much more appropriate context for diving into javascript in your project. Granted they serve different purposes, but in terms of sheer usage, I think jQuery is more widely used than node.js...don't quote me on that! Commented Jul 7, 2014 at 16:37
  • Having said that, if you find a compelling need for node.js in your application, you would almost definitely do what @Oded suggested. You would use HTTP (most likely) to communicate from the main part of your application or web page to/from your node process. I think that's a perfectly valid approach. Commented Jul 7, 2014 at 16:40
  • Your claim is reinforced by something I discovered today. github.com/petkaantonov/bluebird - if you look at this repository, it has different install instructions for node, and for browsers. This suggest to me that you are correct, it is an entirely different process. What I am taking from that is that node.js is more like a compiler than an actual runtime for some things. It looks like you would use node to get the library, and all of the files associated with it, to create something you could use elsewhere.
    – Ciel
    Commented Jul 10, 2014 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.