how can I solve this error in ionic `You must spec

2019-08-25 20:07发布

问题:

I ran ionic start series sidetabs in my Windows and got this error

TypeError: You must specify a "protocol" for the proxy type (http, https, socks, socks4, socks4a, socks5, socks5h, pac+data, pac+file, pac+ftp, pac+http, pac+https)
    at new ProxyAgent (C:\Users\sato\AppData\Roaming\npm\node_modules\@ionic\cli-plugin-proxy\node_modules\proxy-agent\index.js:97:11)
    at ProxyAgent (C:\Users\sato\AppData\Roaming\npm\node_modules\@ionic\cli-plugin-proxy\node_modules\proxy-agent\index.js:81:45)
    at Request.proxy (C:\Users\sato\AppData\Roaming\npm\node_modules\@ionic\cli-plugin-proxy\node_modules\superagent-proxy\index.js:71:15)
    at C:\Users\sato\AppData\Roaming\npm\node_modules\ionic\node_modules\@ionic\cli-utils\lib\http.js:31:17
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\sato\AppData\Roaming\npm\node_modules\ionic\node_modules\tslib\tslib.js:102:62)
    at <anonymous>

How do I solve this?

回答1:

For Windows, enter the SET command without quotes. The plugin cannot identify the protocol from the url if the text contains quotes. Might get fixed in future. As of now, this worked for me,

set HTTP_PROXY=http://proxy.company.com:port-number
set HTTPS_PROXY=http://proxy.company.com:port-number
set IONIC_HTTP_PROXY=http://proxy.company.com:port-number
set PROXY=http

This applies if your proxy is an HTTP proxy. If you have a SOCK proxy, you need to edit accordingly changing the url and proxy=sock



回答2:

my problem was solved with the command npm config unset -g proxy