Error: cordova platform add android

Error: cordova platform add android

我正在为 PhoneGap 使用命令行,然后我创建了要添加平台的项目。当我数字这个:cordova platform add android,我有这个错误:

> npm http GET https://registry.npmjs.org/cordova-android/3.7.1
> TypeError: Request path contains unescaped characters.
>     at new ClientRequest (_http_client.js:73:11)
>     at TunnelingAgent.exports.request (http.js:49:10)
>     at TunnelingAgent.createSocket (C:\Users\AppData\Roaming\np
> m\node_modules\cordova\node_modules\cordova-lib\node_modules\npm\node_modules\re
> quest\node_modules\tunnel-agent\index.js:117:25)
>     at TunnelingAgent.createSecureSocket [as createSocket] (C:\Users\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_mod
> ules\npm\node_modules\request\node_modules\tunnel-agent\index.js:184:41)
>     at TunnelingAgent.addRequest (C:\Users\AppData\Roaming\npm\
> node_modules\cordova\node_modules\cordova-lib\node_modules\npm\node_modules\requ
> est\node_modules\tunnel-agent\index.js:80:8)
>     at new ClientRequest (_http_client.js:154:16)
>     at Object.exports.request (http.js:49:10)
>     at Object.exports.request (https.js:136:15)
>     at Request.start (C:\Users\AppData\Roaming\npm\node_modules
> \cordova\node_modules\cordova-lib\node_modules\npm\node_modules\request\index.js
> :594:30)
>     at Request.end (C:\Users\AppData\Roaming\npm\node_modules\c
> ordova\node_modules\cordova-lib\node_modules\npm\node_modules\request\index.js:1
> 186:28)

我可以修好吗???我设置了代理, Android 的版本是 4.4W.2 (API 20)

这与代理有关,this issue of ionic-cli 人说将节点降级到 0.10.29 即可解决。

此外,如果降级不是一个选项,您可以按照以下步骤更改隧道代理:

  • 将 C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\request\node_modules\tunnel-agent 的内容替换为此 zip 的内容:https://github.com/mikeal/tunnel-agent

  • 配置代理设置:

    npm config set proxy http://proxy:port
    set PROXY=http://proxy:port