I am trying to build d3.js under Windows. I have installed cygwin to run the makefile. However, as part of make install, it calls 'npm install', and this call fails:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'C:\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)
Makefile:230: recipe for target `install' failed
make: *** [install] Error 1
The problems seems to be that the cygwin path prefix ('cygdrive\c') is added to the file path (other than that, the path is correct).
I am wondering if there is a good workaround for this problem? I have tried to export the NODE_PATH variable as well as changing it in the Makefile. However, this does not affect this error (and I would prefer to keep the Makefile as it is).
EDIT: It worked when I called 'npm install' from the Webstorm command line (without cygwin). I had to install contextify (jsdom requirement) manually ('npm install contextify -f' and then copy the .node file from https://github.com/Benvie/contextify/downloads into build/Release for contextify), and to run 'npm install jsdom' and 'npm install vows' afterwards.
You can edit the npm
script so that it is cygwin-aware:
#!/bin/sh
cygwin=false;
case "`uname`" in
CYGWIN*) cygwin=true;
esac
basedir=`dirname "$0"`
if $cygwin; then
basedir=`cygpath -w "$basedir"`
fi
if [ -x "`dirname "$0"`/node.exe" ]; then
"$basedir/node.exe" "$basedir/node_modules/npm/bin/npm-cli.js" "$@"
else
node "$basedir/node_modules/npm/bin/npm-cli.js" "$@"
fi
I don't have a CYGWIN environment variable so pkh's answer didn't work for me, but changing the npm script (by default in C:\Program Files\nodejs) like this should work for all cygwin environments.
#!/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
If you're at a cygwin bash prompt, you can also run npm.cmd instead of npm if you don't want to edit the script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With