curlhttp://npmjs.org/install.sh | sh在Cygwin失败

我无法在cygwin上安装npm。 我已经安装了节点v0.4.12,它应该是cygwin上nodejs的最后支持版本。
这是我得到的错误:

curl http://npmjs.org/install.sh | sh % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 85 0 85 0 0 344 0 --:--:-- --:--:-- --:--:-- 904 sh: line 1: syntax error near unexpected token `newline' sh: line 1: `<html>Moved: <a href="https://npmjs.org/install.sh">https://npmjs.org/install.sh</a>' 

请帮我解决这个问题。 TIA。

该错误是因为该URL以302redirect响应。 你需要使用不同的URL,它只是有一个不同的协议 – httpshttp

 curl https://npmjs.org/install.sh | sh 

不过,正如我在上面的评论中指出的那样,您可以在没有cygwin的情况下在Windows上安装Node 0.8或更高版本。

对不起 – 迟到的游戏,但这对我有用:

 curl https://www.npmjs.org/install.sh | sh 

我知道这是一个旧的post,但我想我会提供一个更新的答案,将作为没有任何答案,因为NPM将执行build议的curl呼叫时返回301 Redirect

在Unix上更新NPM

curl -L https://npmjs.org/install.sh | sudo sh

-L选项告诉curl遵循redirect并在sh之前添加sudo ,以确保避免任何权限问题。

在Windows上更新NPM

在Windows上更新NPM最简单的方法是使用npm-windows-upgrade模块。 按照链接获取有关实际更新程序的说明。

现在的url是https://www.npmjs.org/install.sh

所以完整的安装命令是:

 curl https://www.npmjs.org/install.sh | sh 

这可能会在未来再次发生变化。 有关node和npm的许多安装选项,请参阅官方要求,或者在joyent博客上阅读本指南 。