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.

culix
  • 10,188
  • 6
  • 36
  • 52
Mj1992
  • 3,404
  • 13
  • 63
  • 102
  • 2
    Instead of continuing here as would be ideal, [unfortunately this Q was effectively asked again 1.5 years later at stackoverflow.com/questions/17297422/trouble-with-starting-node-js-from-a-cygwin-console](http://stackoverflow.com/questions/17297422/trouble-with-starting-node-js-from-a-cygwin-console#comment-36204702); as that comment explains, thre is some useful stuff there, but for new stuff, kindly put it here on the first asking. – Destiny Architect May 11 '14 at 04:08

8 Answers8

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')"
Kaiden Prince
  • 472
  • 3
  • 18
troy
  • 496
  • 5
  • 6
  • 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 Apr 19 '14 at 13:31
  • Isn't npm a cmd file? Why use dos2unix on the cmd file? – CMCDragonkai May 18 '14 at 07: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. – David Ferenczy Rogožan May 27 '14 at 14:33
  • The repl doesn't work for me http://stackoverflow.com/questions/17297422/trouble-with-starting-node-js-from-a-cygwin-console#answer-23030836 – Lime Dec 04 '15 at 02: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).

Kat
  • 4,645
  • 4
  • 29
  • 81
  • +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 Feb 14 '16 at 02: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

Petter Thowsen
  • 1,697
  • 1
  • 19
  • 24
  • I just noticed [Google Search(Node-js cygwin)](https://www.google.com/search?q=Node-js+cygwin) find 5 http://nlighteneddevelopment.com/content/nodejs-cygwin also has this (using Console2) as their fix – Destiny Architect May 10 '14 at 09:02
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

xjlin0
  • 341
  • 5
  • 10
  • 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 http://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. – Destiny Architect Feb 01 '15 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
>
千木郷
  • 1,595
  • 2
  • 19
  • 30
  • The OP is already using the cygwin terminal. How does starting bash from cmd.exe answer the question? – Artjom B. Feb 22 '15 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`. – 千木郷 Feb 23 '15 at 09: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 Nov 13 '15 at 08: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 Mar 22 '18 at 02: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.

AnrDaemon
  • 302
  • 2
  • 9
-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.

Community
  • 1
  • 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 Jan 18 '15 at 22:41
-3

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

mihai
  • 37,072
  • 9
  • 60
  • 86
  • 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 Apr 06 '12 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 Apr 06 '12 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 May 01 '13 at 17:49