【问题标题】:Node.js install module on windowsNode.js 在 Windows 上安装模块
【发布时间】:2012-07-22 19:26:51
【问题描述】:

Cmd 错误:“sh”不是内部或外部命令、可运行程序或批处理文件。

C:\Users\user>npm install -g node-curl
    npm http GET https://registry.npmjs.org/node-curl
    npm http 304 https://registry.npmjs.org/node-curl

    > node-curl@0.1.4 install C:\Users\user\AppData\Roaming\npm\node_modules\node-cu
    rl
    > sh src/generate_curl_options_list.sh && node-waf configure build || true

    "sh" is not recognized as an internal or external command, operable program or batch file.
    "true" is not recognized as an internal or external command, operable program or batch file.

【问题讨论】:

    标签: windows node.js module sh


    【解决方案1】:

    扩展弗洛里安的回答:你在 Windows 上,没有 cURLsh。您正在尝试安装一个依赖于您的操作系统的模块,该操作系统提供 libcurl-library 和 sh,Windows 未附带该模块。

    你有一些选择:

    1. 编写您自己的仅节点实现,其行为类似于 curl。

      在 SO 上看到这个问题:Curl equivalent in nodejs? 它详细介绍了如何使用内置的http 模块,例如 curl。

    2. 或者在windows上安装libcurlsh,用cygwin之类的工具。我没有尝试过,您尝试安装的 npm 模块可能仍然依赖于 cygwin 无法解决的其他 unix 工具。

    3. 或者在 http://search.npmjs.org/ 中寻找其他类似 curl 的东西。试试httpsynccurly

    我推荐选项 1,它会教你基本的 http 原则。 node 中的原生模块已经提供了你可能需要 curl 的一切。 :)

    【讨论】:

    • Curl 的主页具有适用于 Win32 和 Win64 的通用二进制文件。通用 sh 克隆广泛可用。
    • 我不知道这些是否有帮助...问题是@newpdv 想要安装一个节点模块但它失败了,或者他想从节点使用 cURL。仅 Javascript 的实现(使用内置模块)可能比在子进程中调用 curl 更好。
    【解决方案2】:

    好吧,在没有 curl 的 windows 上使用 node-curl 是很愚蠢的。

    不要尝试。

    【讨论】:

    • 好的。在 http.request 上使用 cookie 有多容易?
    • 公平地说,node-curl 可能是 curl 命令行工具的 node.js 实现,从名称上并不能立即看出它包装了 curl 的本机实现。
    猜你喜欢
    • 2011-05-17
    • 2011-01-23
    • 1970-01-01
    • 2011-07-28
    • 1970-01-01
    • 1970-01-01
    • 2013-03-05
    • 2020-07-31
    • 2017-07-19
    相关资源
    最近更新 更多