Using nodejs with cygwin (v0.10.25)
I’m using Windows at work and I wanted to make some tests with nodejs. I went to the http://nodejs.org, downloaded the node-v0.10.25.msi
and installed it.
Back to my cygwin, I’m naturally writing:
npm -v
- command not found
A quick google search, and I founding some strange things, they all say that nodejs and cygwin can’t work together:
- http://stackoverflow.com/questions/10043177/node-js-cygwin-not-supported
- http://stackoverflow.com/questions/17297422/trouble-with-starting-node-js-from-a-cygwin-console
But I won’t let it down, and I run:
/cygdrive/c/Program\ Files/nodejs/npm.cmd -v
It’s working!
Next step, just aliasing nodejs and npm in my bash_profile
:
nano ~/.bash_profile
# write at the end : (or echo "" >> ~/.bash_profile)
alias npm="/cygdrive/c/Program\ Files/nodejs/npm.cmd"
alias node="/cygdrive/c/Program\ Files/nodejs/node.exe"
# source ~/.bash_profile
node -v
# v0.10.25
npm -v
# 1.3.24
Nodejs and cygwin aren’t working together ? Nonsense.
Edit:
When I tried npm useradd
I had an EINVAL error
:
npm ERR! Error: EINVAL, invalid argument
npm ERR! at new Socket (net.js:157:18)
npm ERR! at process.stdin (node.js:660:19)
npm ERR! at read (C:\Program Files\nodejs\node_modules\npm\node_modules\read\lib\read.js:18:36)
npm ERR! at readUsername (C:\Program Files\nodejs\node_modules\npm\lib\adduser.js:40:3)
npm ERR! at loop (C:\Program Files\nodejs\node_modules\npm\lib\adduser.js:33:20)
npm ERR! at EventEmitter.adduser (C:\Program Files\nodejs\node_modules\npm\lib\adduser.js:29:3)
npm ERR! at Object.commandCache.(anonymous function) (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:194:11)
npm ERR! at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:83:28)
npm ERR! at process._tickCallback (node.js:415:13)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/isaacs/npm/issues>
The solution was to run the same command on the cmd.exe
and not with cygwin, but then npm publish
worked fine on cygwin.