局域网代理环境下Ionic Framework新建App的方法_ionic 下载 代理-程序员宅基地

转自:http://jasonwatmore.com/post/2014/04/02/Ionic-Framework-Getting-ionic-start-appName-Working-Behind-a-Proxy.aspx

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.

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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.

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
D:\Projects>ionic start myApp tabs
Running start task...
Creating Ionic app in folder D:\Projects\myApp based on tabs project
 
 
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

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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.

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/dipolar/article/details/36669701

智能推荐

四极管:蓝牙和GPS_mc20 室内定位-程序员宅基地

文章浏览阅读799次。最近调试了一块GPS模块。。由于开机瞬间电压过高原因。导致公司把货都停掉了。。折腾了两天。。搞掂。 蓝牙模块不稳定。。无法调试。。已发往产品公司验证。。等待ing。。继续Android。。_mc20 室内定位

linux系统怎样配置IP,LINUX操作系统的IP地址如何配置-程序员宅基地

文章浏览阅读743次。虽然不是每一家用户都会使用LINUX操作系统,但是要学好计算机技术,每一个学生都必须要学会它!因为它很重要,那么今天学习啦小编就给大家说说LINUX操作系统的基本知识-IP地址如何配置吧!下面就跟着学习啦小编一起来看看配置方法吧!LINUX操作系统的IP地址如何配置的方法打开一个terminal,切换到root用户用root用户编辑网卡命令如下:vi /etc/sysconfig/network-..._linux操作系统怎么配置ip地址

CentOS7.6系统OpenSSH升级到openssh-9.3p2(漏洞修复)_openssh 9.3p2之前版本存在安全漏洞-程序员宅基地

文章浏览阅读2.2k次,点赞69次,收藏21次。CentOS 7.6系统自带的ssh版本太老了,存在漏洞,为了避免这些漏洞被利用,需要进行升级修复。_openssh 9.3p2之前版本存在安全漏洞

MPI 和OPENMP 混合编程 实现矩阵LU分解_矩阵lu分解 openmp-程序员宅基地

文章浏览阅读6.3k次,点赞3次,收藏31次。LU分解  将系数矩阵A转变成等价两个矩阵L和U的乘积 ,其中L和U分别是下三角和上三角矩阵。当A的所有顺序主子式都不为0时,矩阵A可以分解为A=LU,且分解唯一。其中L是单位下三角矩阵,U是上三角矩阵。方法: 使用openMP和MPI混合编程现实代码如下:#include "stdio.h"#include "stdlib.h"#i_矩阵lu分解 openmp

sql注入解决方案_if test= sql注入怎么改-程序员宅基地

文章浏览阅读773次。sql注入解决方案mybatis Sql:<if test="safetyPageParam.caseStatus !=null and safetyPageParam.caseStatus != ''"> AND t2.channel_status in (${safetyPageParam.caseStatus})</if>问题: 使..._if test= sql注入怎么改

Properties转换成Map_properties转map-程序员宅基地

文章浏览阅读1.2w次。Properties转换成Mapimport java.util.HashMap;import java.util.Map;import java.util.Properties;import java.util.Set;public class Test { public static void main(String args[]){ Properties prope_properties转map

随便推点

[杂谈]ACM启程-程序员宅基地

文章浏览阅读67次。此处省略一大段传奇的经历。只需要知道的是,现在再次开始使用本博客的唯一原因就是——我进大学有搞ACM的打算。其实本来是没有的,受到某学长的指引和推荐,我觉得这条路在当前确切是绝对的优选。2年没碰过OI了,3年没碰过任何超过NOIP考纲范围内的东西了,一切都需要重头再来,拾起遗失的记忆碎片(好矫情)。据说下一次ACM区域赛就在10月,时间不多啦,希望能够赶上吧。转载于:https:...

NetworkManager 连接无线网络日志_nl80211_cmd_del_station-程序员宅基地

文章浏览阅读1.1k次。Jun 2 15:39:40 kylin-HP-Pavilion-x360-Convertible-14-dw2xxx wpa_supplicant[790]: RTM_NEWLINK: ifi_index=2 ifname=wlo1 operstate=2 linkmode=1 ifi_family=0 ifi_flags=0x1003 ([UP])Jun 2 15:39:40 kylin-HP-Pavilion-x360-Convertible-14-dw2xxx NetworkManager[._nl80211_cmd_del_station

单次事件触发DMA读取多字节SPI数据-程序员宅基地

文章浏览阅读4.3k次,点赞2次,收藏6次。有人想使用定时器事件触发DMA读取SPI数据,希望每一次更新事件仅触发一轮DMA传输,借助DMA实现N字节的SPI数据收发。要完成这个功能,这里推荐两种做法供参考。第一种,先做好SPI的D..._spidma读取

python123百钱买百鸡问题_C语言解决百钱买百鸡问题-程序员宅基地

文章浏览阅读579次。我国古代数学家张丘建在他的《算经》中提出了一个著名的“百钱买百鸡问题”,鸡翁一,值钱五,鸡母一,值钱三,鸡雏三,值钱一,百钱买百鸡,问翁、母、雏各几何?C语言实现过程:第一种(1) 使用 for 语句对 3 种鸡的数先在事先确定好的范围内进行穷举并判断,对满足条件的 3 种鸡的数量按指定格式输出,否则进行下次循环。(2) 程序代码如下:#include int main(){int cock,he..._下面程序百钱百鸡不完整,请在123处填写正确的代码实现题目所属功能

VC++常用命名法和宏定义_c++ 宏命名-程序员宅基地

文章浏览阅读916次。匈牙利命名法规则  一般情况下,变量的取名方式为: + + 。  范围前缀_,类型前缀_,限定词。特殊的类型命名,前缀表示:  类、接口前缀 类型例子备注LmClass LmObject表示类型本身不与范围前缀结合使用IInterface 接口IUnknown  注:类名前缀改为Lm,对于非全局的类最好有语义表示其所属模块。类的实_c++ 宏命名

Android在Java获取组件,获取Android activity上所有的控件-程序员宅基地

文章浏览阅读681次。下面是编程之家 jb51.cc 通过网络收集整理的代码片段。编程之家小编现在分享给大家,也给大家做个参考。/*** @note 获取该activity所有view* @author liuh* */public List getAllChildViews() {View view = this.getWindow().getDecorView();return getAllChildViews(v..._android项目的主控java程序中是通过什么方法找到对应的基本组件

推荐文章

热门文章

相关标签