46

I am trying to install node.js. I followed this tutorial and i am stuck in the middle.

When I write ./configure in my cygwin terminal it says "cygwin not supported". Please help me out Thanks in advance.

1

8 Answers 8

45

Node in my experience runs fine in cygwin, what Node usually has EINVAL errors in seems to be MINTTY which is a terminal emulation 'skin' that is default to cygwin. I still am not sure why these EINVAL errors happen 100% but the following are the steps and tricks I use to get node working.

In my /cygwin/home/{username}/.bashrc I add node to path so cygwin can find it

export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/"

If you run a 32 bit version of node:

export PATH=$PATH:"/cygdrive/c/Program Files (x86)/nodejs/"

Then to make npm run without windows to linux issues I launch cygwin in admin mode then run:

dos2unix '/cygdrive/c/Program Files/nodejs/npm'

At this point running files and most npm packages will run in MINTTY just fine, although every once and awhile you will run into EINVAL issues with certain npm packages as karma. Also you will not be able to run the interpreter directly in MINTTY, anytime I want to do these things I run:

cygstart /bin/bash

This will open a native cygwin bash.exe window, from here you run the interpreter or an any troubling package command that results in a EINVAL. It slightly sucks you have to do this but I rarely use this day to day, and I love MINTTY too much to not use it.

Also note that you can run any one line node code in MINTTY by just running something like:

node -e "console.log('hello node')"
4
  • 1
    I should have probably noted that dos2unix will need to be installed from the cygwin install process or in cygwin via apt-cyg. And Node will need to be installed normally using the windows installer.
    – troy
    Commented Apr 19, 2014 at 13:31
  • Isn't npm a cmd file? Why use dos2unix on the cmd file? Commented May 18, 2014 at 7:33
  • 3
    It is. But there is also "npm" shell script without an extension, which is executed by Cygwin when you use the "npm" command. Actually I don't have a clue, why does that shell script contain Windows line endings. Commented May 27, 2014 at 14:33
  • The repl doesn't work for me stackoverflow.com/questions/17297422/…
    – Lime
    Commented Dec 4, 2015 at 2:03
9

As a simpler derivative of troy's answer for those just looking to install NPM packages:

  1. Install Node.js with the Windows installer package.
  2. Add it to the PATH with export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/" (obviously replacing the path to Node.js's installation directory with where you installed it).
  3. There's a current bug in the Windows version that can be fixed by running mkdir -p ~/AppData/Roaming/npm. This is a bug for all of Windows and not just Cygwin. At some point of the future, you won't have to do this anymore, but the command shouldn't have any negative side effects.
  4. Test it. Eg, npm install pretty-diff -g.
  5. In order to be able to run the newly installed software, you'll need to add the install locations to your PATH. You can find these with npm bin -g and npm bin (the -g flag is the "global" installation location).

Not really anything special that you have to do to get it to run in Cygwin (although I can't say if everything works).

1
  • +1 for simplifying things regarding just NPM (all I need right now). As an update, the latest installer sets PATH to both the Node exe's and the global module area, so all you need to do is restart your shells if you had any open. Steps 2, 3, and 5 can now be skipped. Local npm installs (without -g) made through a Cygwin shell write to node_modules in the current directory, so the user should be able to figure those out on their own. I don't need to PATHify them for require() to work.
    – juanitogan
    Commented Feb 14, 2016 at 2:13
5

Use Console2, it allows you to run create tabs of CLI shells. It seems running cygwin inside console2 allows me to use node REPL just fine. I have no idea why :P

Follow this guide to add cygwin to console2:
http://blog.msbbc.co.uk/2009/11/configuring-console-2-and-bash-with.html

1
0

With Bjørn's suggestion (using Console2) and Soyuka's alias (steps here), my node.js v0.10.13 and npm v1.3.2 are now working under Babun v1.02, a Cygwin distribution. enter image description here

1
  • Very great to hear! Indeed I will soon give that a try and really hope it works. But why are you using a Node.js version which is apparently 1.3 years out-of-date? --given you “answered Dec 15 '14 at 17:07” so when Node “2014.10.20 Version 0.10.33 (Stable)” was latest but you are using "node.js v0.10.13” so from (dated) “2013.07.09 Version 0.10.13 (Stable)”, quoting official nodejs.org/changelog.html . -And how well does it work when, for all softwares (seemingly just Babun, Node, & npm, right?), you use the current stable versions? -as would be the usual & generally-needed thing to do. Commented Feb 1, 2015 at 15:04
0

For windows, Just run bash.exe in cmd, so that you could have a bash work around with cmd console directly, which could support ALL NODE WORKING PERFECTLY.

C:\Users\郷>bash

郷@CHIGIX ~
$ node
>
4
  • The OP is already using the cygwin terminal. How does starting bash from cmd.exe answer the question?
    – Artjom B.
    Commented Feb 22, 2015 at 17:39
  • The emulation from cygwin is just put many exe program files into the cygwin installation directory, which have same name to linux common command/executable binary files.So, you could have bash command environment from cmd.exe of course, which is generally at C:\cygwin64\bin\bash.exe.
    – 千木郷
    Commented Feb 23, 2015 at 9:43
  • 1
    I have experienced a weird behavior when using the cygwin terminal like no npm progress output or yo progress bar but this solution helped me. Make sure to add cygwin64/bin to your PATH though otherwise this solution will not be helpful
    – Sul Aga
    Commented Nov 13, 2015 at 8:44
  • 1
    @ArtjomB. - because several parts of node apparently don't work correctly under the "mintty" terminal emulator that cygwin uses, but work OK if executed from cygwin's bash in a standard windows console.
    – Jules
    Commented Mar 22, 2018 at 2:24
0

I'm using this wrapper in /usr/local/bin/node (note no extension!)

#!/bin/sh

_cmd="$(cygpath -lw -- "$1" )"
shift

"/proc/cygdrive/C/Program Files/nodejs/node.exe" "$_cmd" "$@"

This is far from perfect, as Node do not understand Cygwin directory tree, but works relatively well with relative names.

-1

From Windows, run Cygwin.bat (instead of Cygwin Terminal) then in that run node: see and reply on this answer on this effectively-same question asked 1.5 years later.

1
  • 1
    This link may answer the question, but the basics of the code should be included here and the link should be for reference.
    – worldofjr
    Commented Jan 18, 2015 at 22:41
-3

Grab and run the node.js Windows installer.
In the Cygwin prompt type node
See if it works.

3
  • i've downloaded it,extracted it from cygwin terminal but the same problem occurs.Installer installs the file elsewhere so i did everything from the cygwin terminal and in cygwin the nodejs file installs in home/Dell/nodejs/ folder where i've to write the ./configure command but still the same result
    – Mj1992
    Commented Apr 6, 2012 at 15:44
  • man, if you indeed want to stick with cygwin....don't run the installer from within cygwin. Do it from Windows. When you fire up cygwin make sure node is in your path (C:\Program Files\nodejs).
    – mihai
    Commented Apr 6, 2012 at 20:19
  • 2
    This worked just fine for me on more than one machine. Just install Cygwin, then install Node using their native Windows installer. When you type which node or which npm, it'll resolve to the place Node was installed (maybe this works because Node sees Cygwin and adds its paths to Cygwin's $PATH).
    – Will
    Commented May 1, 2013 at 17:49

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.