Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
791 views
in Technique[技术] by (71.8m points)

unix - How add commands to cygwin - npm

I use cygwin on windows 8.1 to have an Unix shell. But I cannot run commands such as npm from it.

What should I do to do it? Add some kind of env var to cygwin? Why it doesn't use windows PATH?

Edit: Actually I think that I misunderstood the problem here. It looks like npm is found by cygwin but it cannot be used. For instance I can use git from cygwin without any trouble.

$ npm
/cygdrive/d/Logiciels installés/nodejs/npm: line 2: $'
' : command not found
/cygdrive/d/Logiciels installés/nodejs/npm: line 4: $'
' : command not found
/cygdrive/d/Logiciels installés/nodejs/npm: line 5: Syntax error around ? $'in
' ?
'cygdrive/d/Logiciels installés/nodejs/npm: line 5: `case `uname` in

So, it looks actually more like a npm issue.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This seems to be a problem with the npm script as mentioned here, https://github.com/joyent/node/issues/5912

Assuming you have installed nodejs in the default location you can run the following dos2unix command and fix the error.

dos2unix c:/Program Files/nodejs/npm

This fixed my problems with the npm script.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...