Node.js on Windows: Who Needs NPM?

So last night via DZone I get word that Node.js had released a Windows version of the popular Javascript based server environment around the 14th of July. Checking from their site, version 0.5.2 was out, being the second currently unstable release for Windows at the moment. I could not hold back my excitement as I do not run Linux, and we use Node.js extensively in my workplace. I just had to try it.

Setting It Up

So in a matter of minutes, the 9.8MB “node.exe” download was on my system, and without even reading any blogs or instructions, I just knew I had to  setup my Windows CMD Environment variables to point to this executable so I could use it from any folder I wished.

And just like a typical Ghanaian who does not read instructions, I jumped straight at the opportunity to run our socket server we were using in the project. That is when all hell broke loose, at least for a few minutes.

The culprit? Missing packages and libraries. I half expected that, just wanted to try without them for the fun of it.

So the next step, find and download the needed libraries. What are they? Just two actually,

  1. Node MySQL Native

Easy peasy, so how do you download them for use by Node on Windows? In Linux I would setup NPM (Node Package Manager) and easily execute a call like

npm install mysql

to get a mysql package from the online repo. But I don’t have NPM on Windows, because apparently the current  version does not support child_process.spawn. That’s a bummer. So how do you do get it run.

The Steps

  1. Download the required package directly from the github repo in .zip format
  2. Place it in the same folder as the node.exe executable
  3. Unpackage the archive and rename the contained folder it as it would have been named if it were to be downloaded via npm. In the case of the mysql package, I renamed the folder from “felixge-node-mysql-6a40e53” to simply “mysql”.
  4. That’s all

Who needs NPM on Windows. Here are the packages downloaded

Btw, I had issues when trying to install Apparently, our company is running version 0.6.2 and the current version from the repo is 0.7.7 which depends on three extra packages in order to run. I had to revert and download the 0.6.2 package in order for things to work.

Happy Node Development y’all!

19 thoughts on “Node.js on Windows: Who Needs NPM?

  1. Nice to see some people using it on windows.
    Note that with new version of npm (1.x) you should just execute `npm install` in your project directory.

    Also note that npm would create a node_modules directory in this very same project directory and populate it with your dependencies. =) I think it sould work on windows too.

    1. Please ensure to have a bit more documentation on this when it goes up, I’m just a lil bit confused by the description given here. Nice to see NPM will be hitting Windows soon.

      Btw, when the new NPM is released, will this particular solution still work? Note: the project folder for me, is outside the node installation folder.

      1. Actually the first one (`npm install`) only works if your dependencies are described in a package.json. see . However, I don’t know when Isaac plans to release npm on windows but last time I heard about it, it wasn’t anytime soon.

        since 1.x npm defaults to “local” installation. This means that it downloads the packages you need and put them in a node_modules folder inside your project directory (the location of your project is not important). ‘node_modules’ is a special name in which node will lookup file when you call require(). doc is here

    1. Unfortunately Kris, I don’t at the moment. If I ever find out, I will be sure to update on it.

    2. To get coffeescript working, do the following:

      1. Follow the instructions above to create the NODE_PATH environment variable and add it to your PATH variable.
      2. Create a folder called node_modules inside the NODE_PATH folder.
      3. Download the coffeescript zip file from github, and extract it to the node_modules folder.
      4. Rename the extracted folder to coffee-script.
      5. Add a second environment variable called COFFEE. Set the value of the COFFEE environment variable to %NODE_PATH%\coffee-script\bin\coffee

      Now you can run coffeescript at the command line by typing node %coffee%. For example, to compile you’d type:

      node %coffee% -c

      Warning: I haven’t tested this extensively, and I expect it’s quite flakey. It will at least get you up and running until npm is available on Windows or until someone else figures out a better way to get it working in Windows.

      1. Oops, I made a mistake in typing my last comment. You should set the COFFEE variable to: %NODE_PATH%\node_modules\coffee-script\bin\coffee

  2. I did not have the same luck with Express. When there is a lot of external dependencies, managing all that manually becomes a hell. I couldn’t get Express to run by manually copying all the dependencies in the node_modules folder.

    1. Depends on your OS, but if you are on windows, then all the instructions you need are per this blog post.

      1. My OS is Windows7. I set an EnvironVar %NODE% for c:\node\node.exe
        So I just start command-line (cmd) and type %node% c:\node\node.couchapp but I get an Error:
        PS C:\node> .\node.exe .\node.couchapp

        throw e; // process.nextTick error, or 'error' event on first tick
        Error: Cannot find module 'watch'
        at Function._resolveFilename (module.js:318:11)
        at Function._load (module.js:263:25)
        at Module.require (module.js:341:17)
        at require (module.js:352:17)
        at Object. (C:\node\node.couchapp\main.js:4:13)
        at Module._compile (module.js:416:26)
        at Object..js (module.js:434:10)
        at Module.load (module.js:335:31)
        at Function._load (module.js:294:12)
        at Array. (module.js:454:10)

        and similar error with

        throw e; // process.nextTick error, or 'error' event on first tick
        Error: Cannot find module ''
        at Function._resolveFilename (module.js:318:11)
        at Function._load (module.js:263:25)
        at Module.require (module.js:341:17)
        at require (module.js:352:17)
        at Object. (C:\node\\lib\
        at Module._compile (module.js:416:26)
        at Object..js (module.js:434:10)
        at Module.load (module.js:335:31)
        at Function._load (module.js:294:12)
        at Module.require (module.js:341:17)

      2. I would recommend you follow the example in this blog exactly, especially with the environment variable name, i.e. %NODE_PATH% instead of %NODE% and let it point to the directory and not the .exe. Then lastly, ensure to have the ‘watch’ and ‘’ modules in the same folder as well.

        On Sun, 04 Sep 2011 15:25 BST

  3. on windows i build node with cygwin and im able to use npm in my cygwin shell, most modules like, express or mongoose worked out of the box, for me better than the node.exe and all the hastle that goes with it

  4. This approach did not work for me with lightnode module, I had to reference the module script location directly from the run script to get it to work.

Comments are closed.