Coding

Node.js and CoffeeScript on Windows, Redux


Remember back when we installed Node.js on a Virtual Machine just to get it working on Windows 7? Well there’s a better way.

1) Install Cygwin

Grab Cygwin from here and install that puppy. Make sure you install the following modules:

  • Devel -> gcc4-g++ [Builds v0.4.2 and earlier use gcc-g++]
  • Devel -> git
  • Devel -> make
  • Devel -> openssl-devel
  • Devel -> pkg-config
  • Devel -> zlib-devel
  • Editors -> nano
  • Libs -> openssl-devel
  • Python -> python

Ensure you allow Cygwin to install required packages as well, otherwise these things just won’t work.

2) Download and build Node.js

$ cd ~
$ git clone git://github.com/joyent/node.git
$ cd node
$ git fetch --all
# if the above fails complaining --all is not recognised, try: git fetch origin
$ git tag
$ git checkout [latest stable tag from previous command, e.g., v0.2.5]
$ ./configure
$ make
$ make install

If, during the “configure” step, you get the following error: “error: could not configure a cxx compiler!” Do the following:

  1. Close your Cygwin terminal.
  2. Start -> Run -> ash
  3. /bin/rebaseall
  4. Close ash, re-open your Cygwin shell, and try again.

3) Configure Node.js

Node.js tries to use /etc/resolv.conf for domain name resolution, all pretending like its on Linux. Simple enough to get around though, just “nano /etc/resolv.conf” to create it. Slap the following in there:

nameserver 8.8.8.8
nameserver 8.8.4.4

Hit Ctrl-O to save. Now Node.js will route DNS requests through Google’s free DNS service.

4) Install NPM

This one’s easy. Run this:

curl http://npmjs.org/install.sh | sh

5) Install CoffeeScript

This is easy because we installed npm:

npm install -g coffee-script

6) Configure your system’s PATH

Open up Control Panel and search for PATH. Click on “Edit the system environment variables”, then click the “Environment Variables” button. Scroll through the “System Variables” list until you find “Path”, then add this to the end:

c:\cygwin\usr\local\bin

If you installed Cygwin to a different spot, make that modification now.

Ta-daa!

Congratulations! Node.js and CoffeeScript are now installed in Cygwin under Windows 7. You can call node.js from a cmd.exe window now due to that PATH variable, and even calling CoffeeScript is super-easy:

node /usr/local/lib/node_modules/coffee-script/bin/coffee {arguments}

Thanks to the offical guide on how to install CoffeeScript on Windows, and to the authors and maintainers of Node.js and CoffeeScript as well.

Coding
Rage-quit support for fish shell
Coding
Code faster with simple Sublime Text improvements
Coding
Gulp.js – an AMAZING build system!
  • Bas Jansen`

    Bas Jansen`Bas Jansen`

    Author

    Dan,

    I found this page and it gave me a quick start, thanks!

    There is only one thing I stumbled on and that is you mention a file called /etc/resolve.conf but it should be /etc/resolv.conf

    Bas


  • Dan Hulton

    Dan HultonDan Hulton

    Author

    Good catch, I’ll fix that right now!


  • hybridwebtech

    hybridwebtechhybridwebtech

    Author

    Ohhhh… why I love/hate open source!

    First off, many thanks for taking the time to work out this procedure.

    Doesn’t quite work on my system, and I wonder if you could supply a few pointers.

    1. downloaded & installed most recent CygWin.

    2. followed your steps up to ./configure, and thats where things went off the rails:

    $ ./configure
    Checking for program g++ or c++ : /usr/bin/g++
    0 [main] python 5468 C:\cygwin\bin\python.exe: *** fatal error – unable to remap \\?\C:\cygwin\lib\python2.6\lib-dynload\time.dll to same address as parent: 0x360000 != 0x3E0000

    Any pointers would be greatly appreciated.


  • Dan Hulton

    Dan HultonDan Hulton

    Author

    I just tried it again, and it worked fine for me. I hate to give you the “Well, it works HERE” answer, but that’s all I got, sorry.

    Good luck getting it working, though.


  • hybridwebtech

    hybridwebtechhybridwebtech

    Author

    Thanks for trying. I may just see if I can install an older version of CygWin.


  • kunz

    kunzkunz

    Author

    Thanks for your post!
    I was only able to install npm after installing nodejs on version 0.4.1 (not 0.4 as mentioned sometimes), otherwise the “can not find module graceful-fs” error showed up.
    I also faced the following error:
    npm ERR! couldn’t unpack /tmp/npm-1312635607031 …
    which I simply eliminated by running cygwin.bat as administrator (as mentionend in the error description)


  • TjD

    TjDTjD

    Author

    Greetings,

    latest stable for cygwin I found to be 0.5.0 ( 0.5.3 and master do not work for sure ).

    T.


  • Amir Rajan

    Amir RajanAmir Rajan

    Author

    Thanks for the write up. I had to use version 0.4.10 of node js to get it working. I tried 0.5.0+ and got an error.


  • irv

    irvirv

    Author

    This mostly worked for me. I found the latest version of node kept giving me an error (Cannot find module ‘graceful-fs’) when attempting to install npm. I backed off to node version 0.4.8 and all went fine after that. Also ./configure was happier after I installed libapr-devel (the absence did not cause failure but the make was far more robust with it than without).

    Thanks for writing this up. Installs on Windows are always a problem and it’s nice to have a single writeup to work with, It can save hours of googling.


  • paranoidfish

    paranoidfishparanoidfish

    Author

    @hybridwebtech
    Hey I had exactly the same error message, I deleted the Cygwyn dir, reinstalled from a different mirror, ensuring all packages mentioned above were installed and tried again.

    This time I got the (semi-expected) ‘could not configure a cxx compiler!’ error, fixed it as suggested (although I had to run dash from Cygwyn dir) and hey presto, working as expected


  • paul

    paulpaul

    Author

    so there is a plugin for netbeans IDE that creates a coffee script you right -compile and boom.. you have it COFFEE am trying out this too as well thanx