Alessandro
Alessandro

Reputation: 925

Error: cordova platform add android

I'm using command line for PhoneGap and after that I created the project I want to add platform. When I digit this: cordova platform add android, I have this error:

> 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)

Can I fix it??? I set my proxy and the version of Android is 4.4W.2 (API 20)

Upvotes: 2

Views: 1069

Answers (1)

Kangcor
Kangcor

Reputation: 1189

It's related to the proxy, in this issue of ionic-cli people say downgrading node to 0.10.29 solves it.

Also, if downgrade is not an option, you can change the tunnel agent following this steps:

  • Replace the content of C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\request\node_modules\tunnel-agent with the content of this zip: https://github.com/mikeal/tunnel-agent

  • Configure the proxy settings:

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

Upvotes: 2

Related Questions