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. 在 root 下执行 Oracle 程序时找不到 libclntsh.so.11.1 错误的解决办法。

    在 root 下执行 Oracle 程序时找不到 libclntsh.so.11.1 错误的解决办法. 先确定 libclntsh.so.11.1 所在目录: [oracle@localhost ~] ...

  2. mxgraph进阶(二)mxgraph的初步介绍与开发入门

    mxgraph的初步介绍与开发入门 前言 由于小论文实验需求,需要实现根据用户日志提取出行为序列,然后根据行为序列生成有向图的形式,并且连接相邻动作的弧上标有执行此次相邻动作的频次.为此,在大师兄徐凯 ...

  3. 【翻译】从Store生成Checkbox Group

    原文:Ext JS: Generating a Checkbox Group from a Store Ext JS的checkbox group可以用来将复选框组合成一个单一的逻辑字段.由于复选框时 ...

  4. java组播MulticastSocket

    在单播模式中有服务器端和客户端之分,而组播模式与单播模式不同,每个端都是以路由器或交换机做为中转广播站,任意一端向路由器或交换机发送消息,路由或交换机负责发送其他节点,每个节点都是同等的.所以在编程模 ...

  5. MiseringThread.java 解析页面线程

    MiseringThread.java 解析页面线程 http://injavawetrust.iteye.com package com.iteye.injavawetrust.miner; imp ...

  6. java实现http的post和get

    前话说一句:conn.setDefaultRequestProperty(key, value);这个函数是设置属性的,其实可以没有!   自己写了一个简单的get,容易控制 public stati ...

  7. Python2.x的UnicodeEncodeError: ‘ascii’ codec can’t encode异常错误

    刚遇到这个问题的时候,在网上找了 半天,发现都是说 添加如下三行代码即可解决问题, [python] import sys reload(sys) sys.setdefaultencoding('ut ...

  8. Java 截取中英文混合字符串

    题目: 编写一个截取字符串的函数,输入为一个字符串和字节数,输出为按字节截取的字符串. 但是要保证汉字不被截半个,如"我ABC"4,应该截为"我AB",输入&q ...

  9. Swift基础之UITableView(之前写的知识点都是最新的2.2版本样式,欢迎大家参考,可以相互交流)

    //这里只是列举了经常使用的UITableView的属性和方法,其他的都可以类似使用,注意用法即可     //设置全局变量UITableView     var myTableView = UITa ...

  10. 网站开发进阶(二十一)Angular项目信息错位显示问题解决

    Angular项目信息错位显示问题解决 绪 最近在项目开发过程中遇到这样一个棘手的问题:查询出所有订单信息后,点击选择某一个订单,查询出的结果是上一次查询所得的结果.而且会出现点击两次才可以显示订单详 ...