Skip to content
This repository

Path problems on Windows in cygwin #2465

Closed
pkhpkh opened this Issue May 21, 2012 · 14 comments

6 participants

Phillip Howell Isaac Z. Schlueter ronin712 Ty katowulf gbakernet
Phillip Howell
pkhpkh commented May 21, 2012

[ Since I can't request a reopening of #2384, I'm submitting a duplicate. ]

When attempting to use the npm script under Cygwin in Windows, I receive the following error:

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Cannot find module 'H:\cygdrive\c\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js'
    at Function._resolveFilename (module.js:332:11)
    at Function._load (module.js:279:25)
    at Array.0 (module.js:479:10)
    at EventEmitter._tickCallback (node.js:192:40)

There are some cases where running in cmd.exe is not feasible (3rd party makefiles, e.g.). And we can do better: a simple change to the npm script to make it cygwin-aware will resolve this problem.

ronin712

Here is an updated npm script that does the right thing under cygwin and should be POSIX compatible. Tested on cygwin/Windows and on OS X.

#!/bin/sh

NODE_DIR=`dirname "$0"`
case `uname` in
    *CYGWIN*) NODE_DIR=`cygpath -w "$NODE_DIR"`;;
esac

if [ -x "`dirname "$0"`/node.exe" ]; then
  "`dirname "$0"`/node.exe" "$NODE_DIR/node_modules/npm/bin/npm-cli.js" "$@"
else
  node "$NODE_DIR/node_modules/npm/bin/npm-cli.js" "$@"
fi
Isaac Z. Schlueter
Owner
isaacs commented June 04, 2012

Cygwin is not supported. Please use the windows native build with cmd, powershell, or msys git bash.

Isaac Z. Schlueter isaacs closed this June 04, 2012
Ty

May I ask why cygwin isn't supported? I don't know anyone that uses cmd or powershell. Git bash is great, but Cygwin is, for many, the default programming environment.

Isaac Z. Schlueter
Owner
isaacs commented June 05, 2012

@TyOverby Cygwin is pretty terrible if your program does a lot with child processes and low-level filesystem IO. That rant is best saved for some time in person with a few drinks. Node never worked well under Cygwin, and npm was worse. It's much faster and more stable to go direct to the OS.

Ty

Fair enough. Not what I wanted to hear, but if performance is the reason, I'm all for it.

Isaac Z. Schlueter
Owner
isaacs commented June 05, 2012

We could probably get decent performance, but it's just not worth the work it would take to get there.

Phillip Howell
pkhpkh commented June 06, 2012
Ty

Yeah, the only problem that I was having with it on cygwin was that npm was trying to look for modules in the wrong (cygwin only) directory. (Node itself worked just fine)

Isaac Z. Schlueter
Owner
isaacs commented June 06, 2012

Path issues are about 90% of the pain of getting something to work on windows. The performance of node.exe is much better than the cygwin-compiled node binary, but it's still unnecessarily difficult to get everything working properly, since node and npm on windows assume that the paths will behave like windows paths.

This is not going to happen, sorry. It's not nearly valuable enough to justify the considerable cost.

Ty

I got it working fairly easily today, so I will just post this here in case anyone stumbled upon it from Google. The basic idea is that you create symlinks to the folders that node uses.

Often times, npm and node will look for c:/cygdrive/c/...... which doesn't exist because it is faked by cygwin. But what you can do is create the c:/cygdrive/c/ folder and then make symlinks inside of those.

Please note that you have to use the windows symlink function "MKLINK /D to from"

The symlinks that I created to get npm and CoffeeScript working were:

From To
C:\Program Files (x86)\nodejs C:\cygdrive\c\Program Files (x86)\nodejs
C:\Users C:\cygdrive\c\Users

This tricks npm and node into actually going to the right directory to look for these things.

I'm not sure if these are all of the paths that need to be symlinked and I'm also not sure if this will break anything, so use at your own risk.

Edit: If someone would provide me all of the paths that Node uses, I'd be happy to compile and write an installation script of some sort.

katowulf

@isaacs, for a lot of us it's not about what's terrible or great but simply a matter of calling npm install on the many dependencies needing Make.

The solutions seems to be Cygwin, ming-gw, or GnuWin.

Each of these presents its own list of incompatibilities and issues to correct, but Cygwin is a nearly perfect match, if that damned path just worked so I could get my package dependencies working without a fuss. : (

Isaac Z. Schlueter
Owner
isaacs commented June 10, 2012

I'd accept a small low-impact patch for this if someone wants to write it. It's just that I don't consider cygwin support relevant enough to spend time on. When you come to me complaining that Node and npm perform like crap on Cygwin and leave lots of orphaned processes, you'll have my sympathy, but also my "I told you so". It's awful.

Phillip Howell
pkhpkh commented June 10, 2012

Small, low-impact patch submitted. I've been using it for the better part of a month without issue. Thanks for taking it.

Also: I'm using Cygwin, I'm used to everything performing like crap. Unfortunately, it's better than any alternative I've found when I'm stuck on Windows.

Isaac Z. Schlueter isaacs referenced this issue from a commit in joyent/node June 18, 2012
Isaac Z. Schlueter 2012.06.19, Version 0.7.12 (unstable)
* npm: Upgrade to 1.1.29
- Improved 'npm init'
- Fix the 'cb never called' error from 'oudated' and 'update'
- Add --save-bundle|-B config
- Fix npm/npm#2465: Make npm script and windows shims cygwin-aware
- Fix npm/npm#2452 Use --save(-dev|-optional) in npm rm
- `logstream` option to replace removed `logfd` (Rod Vagg)
- Read default descriptions from README.md files

* Shims to support deprecated ev_* and eio_* methods (Ben Noordhuis)

* #3118 net.Socket: Delay pause/resume until after connect (isaacs)

* #3465 Add ./configure --no-ifaddrs flag (isaacs)

* child_process: add .stdin stream to forks (Fedor Indutny)

* build: fix `make install DESTDIR=/path` (Ben Noordhuis)

* tls: fix off-by-one error in renegotiation check (Ben Noordhuis)

* crypto: Fix diffie-hellman key generation UTF-8 errors (Fedor Indutny)

* node: change the constructor name of process from EventEmitter to process (Andreas Madsen)

* net: Prevent property access throws during close (Reid Burke)

* querystring: improved speed and code cleanup (Felix Böhm)

* sunos: fix assertion errors breaking fs.watch() (Fedor Indutny)

* unix: stat: detect sub-second changes (Ben Noordhuis)

* add stat() based file watcher (Ben Noordhuis)
5d6d4c1
Isaac Z. Schlueter isaacs referenced this issue from a commit June 19, 2012
Commit has since been removed from the repository and is no longer available.
Isaac Z. Schlueter isaacs referenced this issue from a commit June 19, 2012
Commit has since been removed from the repository and is no longer available.
Isaac Z. Schlueter isaacs referenced this issue from a commit June 19, 2012
Commit has since been removed from the repository and is no longer available.
Isaac Z. Schlueter isaacs referenced this issue from a commit in joyent/node June 18, 2012
Isaac Z. Schlueter 2012.06.19, Version 0.7.12 (unstable)
* npm: Upgrade to 1.1.30
  - Improved 'npm init'
  - Fix the 'cb never called' error from 'oudated' and 'update'
  - Add --save-bundle|-B config
  - Fix npm/npm#2465: Make npm script and windows shims cygwin-aware
  - Fix npm/npm#2452 Use --save(-dev|-optional) in npm rm
  - `logstream` option to replace removed `logfd` (Rod Vagg)
  - Read default descriptions from README.md files

* Shims to support deprecated ev_* and eio_* methods (Ben Noordhuis)

* #3118 net.Socket: Delay pause/resume until after connect (isaacs)

* #3465 Add ./configure --no-ifaddrs flag (isaacs)

* child_process: add .stdin stream to forks (Fedor Indutny)

* build: fix `make install DESTDIR=/path` (Ben Noordhuis)

* tls: fix off-by-one error in renegotiation check (Ben Noordhuis)

* crypto: Fix diffie-hellman key generation UTF-8 errors (Fedor Indutny)

* node: change the constructor name of process from EventEmitter to process (Andreas Madsen)

* net: Prevent property access throws during close (Reid Burke)

* querystring: improved speed and code cleanup (Felix Böhm)

* sunos: fix assertion errors breaking fs.watch() (Fedor Indutny)

* unix: stat: detect sub-second changes (Ben Noordhuis)

* add stat() based file watcher (Ben Noordhuis)
a721201
gbakernet

Thank you for this.

Bryan Bishop kanzure referenced this issue from a commit September 29, 2012
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.