This is a quick hacky way to get the ionic start [appName] command working from behind a proxy. I ran into the problem going through the steps on the Getting Started with Ionic page. For some reason the ionic cmd doesn't use the npm proxy or git proxy settings.

I did this on a Windows 7 machine but the same should work in another OS just the file locations will be different.

1. Add the proxy url to request.js located at 'C:\Users\[username]\AppData\Roaming\npm\node_modules\ionic\node_modules\request\request.js'. Here's the update including the lines just before and after so you can find where to put it.

  if (self.strictSSL === false) {
self.rejectUnauthorized = false
} // hack to add proxy
self.proxy = 'http://10.68.0.5:8080'; if (self.proxy) {
if (typeof self.proxy == 'string') self.proxy = url.parse(self.proxy) // do the HTTP CONNECT dance using koichik/node-tunnel
if (http.globalAgent && self.uri.protocol === "https:") {
var tunnelFn = self.proxy.protocol === "http:"
? tunnel.httpsOverHttp : tunnel.httpsOverHttps var tunnelOptions = { proxy: { host: self.proxy.hostname
, port: +self.proxy.port
, proxyAuth: self.proxy.auth
, headers: { Host: self.uri.hostname + ':' +
(self.uri.port || self.uri.protocol === 'https:' ? 443 : 80) }}
, rejectUnauthorized: self.rejectUnauthorized
, ca: this.ca } self.agent = tunnelFn(tunnelOptions)
self.tunnel = true
}
}

2. Add the proxy url to registry.js located at 'C:\Users\[username]\AppData\Roaming\npm\node_modules\cordova\node_modules\plugman\src\registry\registry.js', again I've included the lines around the hack so you can find where to put it.

  headers.accept = "application/json"

  headers["user-agent"] = settings['user-agent'] ||
'node/' + process.version // hack to add proxy
var p = settings.proxy || 'http://10.68.0.5:8080'
var sp = settings['https-proxy'] || p
opts.proxy = remote.protocol === "https:" ? sp : p // figure out wth 'what' is
if (what) {
if (Buffer.isBuffer(what) || typeof what === "string") {
opts.body = what
headers["content-type"] = "application/json"
headers["content-length"] = Buffer.byteLength(what)
} else {
opts.json = what
}
}

That's it! You should now be able to create ionic apps without an issue.

Just in case people are searching for how to do this by googling the command line errors, I've included them below.

First error

D:\Projects>ionic start myApp tabs
Running start task...
Creating Ionic app in folder D:\Projects\myApp based on tabs project DOWNLOADING: https://github.com/driftyco/ionic-app-base/archive/master.zip TypeError: Cannot read property 'statusCode' of undefined
at Request._callback (C:\Users\watmorj\AppData\Roaming\npm\node_modules\ionic\lib\ionic.js:241:13)
at self.callback (C:\Users\watmorj\AppData\Roaming\npm\node_modules\ionic\node_modules\request\request.js:129:22)
at Request.EventEmitter.emit (events.js:95:17)
at ClientRequest.self.clientErrorHandler (C:\Users\watmorj\AppData\Roaming\npm\node_modules\ionic\node_modules\request\request.js:239:10)
at ClientRequest.EventEmitter.emit (events.js:95:17)
at CleartextStream.socketErrorListener (http.js:1547:9)
at CleartextStream.EventEmitter.emit (events.js:95:17)
at Socket.onerror (tls.js:1445:17)
at Socket.EventEmitter.emit (events.js:117:20)
at net.js:441:14

Second error

Initializing cordova project.
Fetching plugin "org.apache.cordova.device" via plugin registry
Error: Failed to fetch package information for org.apache.cordova.device
at C:\Users\watmorj\AppData\Roaming\npm\node_modules\cordova\node_modules\plugman\src\registry\registry.js:32:20
at Request.cb [as _callback] (C:\Users\watmorj\AppData\Roaming\npm\node_modules\cordova\node_modules\plugman\src\registry\registry.js:251:9)
at self.callback (C:\Users\watmorj\AppData\Roaming\npm\node_modules\cordova\node_modules\plugman\node_modules\request\index.js:148:22)
at Request.EventEmitter.emit (events.js:117:20)
at ClientRequest.self.clientErrorHandler (C:\Users\watmorj\AppData\Roaming\npm\node_modules\cordova\node_modules\plugman\node_modules\request\index.js:257:10)
at ClientRequest.EventEmitter.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1547:9)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:441:14
at process._tickCallback (node.js:415:13)
ERROR: Unable to add plugins. Perhaps your version of Cordova is too old. Try updating (npm install -g cordova), removing this project folder, and trying again.
Exiting.

Ionic Framework - Getting 'ionic start [appName]' Working Behind a Proxy的更多相关文章

  1. 170多个Ionic Framework学习资源(转载)

    在Ionic官网找到的学习资源:http://blog.ionic.io/learning-ionic-in-your-living-room/ 网上的文章比较多,但是很多时候我们很难找到自己需要的. ...

  2. Mobile first! Wijmo 5 + Ionic Framework之:Hello World!

    本教程中,我们用Wijmo 5 和 Ionic Framework实现一个Mobile的工程:Hello World. Ionic是什么? Ionic是一个HTML5框架.免费.开源,用于帮助生成hy ...

  3. Hybrid UI framework shootout: Ionic vs. Famo.us vs. F7 vs. OnsenUI

    1 Introduction In the past 2 years I’ve been working intensively on mobile applications, mostly hybr ...

  4. Wijmo 5 + Ionic Framework之:费用跟踪 App

    Wijmo 5 + Ionic Framework之:费用跟踪 App 费用跟踪应用采用了Wijmo5和Ionic Framework创建,目的是构建一个hybird app. 我们基于<Mob ...

  5. Wijmo 5 + Ionic Framework之:Hello World!

    Wijmo 5 + Ionic Framework之:Hello World! 本教程中,我们用Wijmo 5 和 Ionic Framework实现一个Mobile的工程:Hello World. ...

  6. Mobile first! Wijmo 5 + Ionic Framework之:费用跟踪 App

    费用跟踪应用采用了Wijmo5和Ionic Framework创建,目的是构建一个hybird app. 我们基于<Mobile first! Wijmo 5 + Ionic Framework ...

  7. 一:Ionic Framework初体验

    因项目关系,需要开发一个平板使用的应用程序,刚开始以为需要使用Andriod,后来经理提供了一个解决方案,Ionic Framework https://ionicframework.com/ 第一步 ...

  8. 十分钟使用ionic Framework开发一个跨平台移动应用

    Ionic是一个前端的框架,帮助开发人员使用HTML5, CSS3和JavaScript做出原生应用. ionic的理念类似前端开发的BootStrap,目标是封装HTML5移动跨平台开发的最佳实践. ...

  9. 13本热门书籍免费送!(Python、SpingBoot、Entity Framework、Ionic、MySQL、深度学习、小程序开发等)

    七月第一周,网易云社区联合清华大学出版社为大家送出13本数据分析以及移动开发的书籍(Python.SpingBoot.Entity Framework.Ionic.MySQL.深度学习.小程序开发等) ...

随机推荐

  1. C语言实现4种常用排序

    实在没事搞,反正面试也要用到,继续来写4种排序算法.因为那天用java写了排序,突然想到我是要面试IOS,起码也得用C写.C竟然忘干净了,方法都不会写了.囧啊! 下面用C实现4种排序算法:快速排序.冒 ...

  2. 1017. Queueing at Bank (25) - priority_queuet

    题目如下: Suppose a bank has K windows open for service. There is a yellow line in front of the windows ...

  3. Java数组与函数的结合

    import java.util.Scanner; public class HelloWorld { public static void main(String[] args){ // Scann ...

  4. Android实训案例(九)——答题系统的思绪,自己设计一个题库的体验,一个思路清晰的答题软件制作过程

    Android实训案例(九)--答题系统的思绪,自己设计一个题库的体验,一个思路清晰的答题软件制作过程 项目也是偷师的,决心研究一下数据库.所以写的还是很详细的,各位看官,耐着性子看完,实现结果不重要 ...

  5. JAVA DOM4j解析XML数据到自定义javabean

    我们获取xml中的数据,一般以面向对象的思想去处理这些数据.因此,我们需要自定义类来封装解析出来的数据,以方便我们操作这些数据. 自定义的java类,称为javabean. 自定义Contact类代码 ...

  6. VisualSVN Server安装过程

     运行VisualSVN-Server-2.7.3.msi程序, 如下图 点击Next, 下一步 选中 I accept选项, 点击Next, 下一步 选择默认配置, 服务和控制台组件方式, 点击 ...

  7. MFC中使用SDL播放音频没有声音的解决方法

    本文所说的音频是指的纯音频,不包含视频的那种. 在控制台中使用SDL播放音频,一般情况下不会有问题. 但是在MFC中使用SDL播放音频的时候,会出现没有声音的情况.经过长时间探索,没有找到特别好的解决 ...

  8. Linux程序分析工具介绍—ldd,nm

    原文链接:http://blog.csdn.net/statdm/article/details/7759100 本文要介绍的ldd和nm是linux下,两个用来分析程序很实用的工具.ldd是用来分析 ...

  9. dos2unix(windows脚本文件放到unix下运行要注意)

    在windows下编写的shell脚本文件,直接放到linux下运行,是不行的. infiniDB的倒库脚本文件load.sh,将tbl文件导入infiniDB,怎么运行不成功,不建job.运来,是w ...

  10. 嵌入式C开发---用循环实现左移右移

    //将n左移m位 int byte_to_left_move(int n , int m) { int i , ret = 1 ; if(n == 0 || n < 0) { return ; ...