Ionic io behind Proxy

I cannot upload my app to my account, im behind a company proxy. To start the app i configured the proxy, but for the ionic io command, it gives me the following error:

C:\MyIonic2Project>ionic io init
Initializing app with ionic.io
An error occurred initializing the app: Error: tunneling socket could not be established, cause=getaddrinfo ENOTFOUND 3140 3140:80

You can try it with the new CLI Beta 8

https://github.com/driftyco/ionic-cli/tree/v3

In the readme you find a part about CLI with PROXY: https://github.com/driftyco/ionic-cli/tree/v3#using-a-proxy

To proxy CLI requests, you will first need to install a CLI plugin:

$ npm install --save-dev @ionic/cli-plugin-proxy

Then, set any of the following environment variables:

$ export http_proxy=http://internal.proxy.com
$ export HTTP_PROXY=http://internal.proxy.com
$ export PROXY=http://internal.proxy.com
$ export IONIC_HTTP_PROXY=http://internal.proxy.com

For example:

$ HTTP_PROXY=http://internal.proxy.com ionic login

My enviroment variables are already set to:

http_proxy=http://myproxy:myport
HTTP_PROXY=http://myproxy:myport
HTTPS_PROXY=http://myproxy:myport
PROXY=http://myproxy:myport
IONIC_HTTP_PROXY=http://myproxy:myport

But i still getting this error, now when i create a new app:

C:\Users\weslley.rocha\Documents\asfdaf>ionic start MyFirstApp tutorial
✖ Downloading 'tutorial' starter template - failed!
{ Error: connect ENOTCONN 192.30.253.112:443
    at Object.exports._errnoException (util.js:1050:11)
    at exports._exceptionWithHostPort (util.js:1073:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1097:14)
  code: 'ENOTCONN',
  errno: 'ENOTCONN',
  syscall: 'connect',
  address: '192.30.253.112',
  port: 443,
  response: undefined }

Do you use the new CLI Beta?

I also have a short workaround for that kind of problem. Some people have problems with the download of the templates from GitHub.
You can also download them by yourself.

Download this: https://github.com/driftyco/ionic2-starter-tutorial
and this: https://github.com/driftyco/ionic2-app-base

Unzip both into the same folder and run npm install

Well, i tried this, but looks like it install in a folder called “ionic-app-base”, and when i run the ionic start MyFirstApp tutorial it tries to download again

I explain you now what the CLI do when you type ionic start HelloWorld tutorial

Step 1. The CLI downloads the app-base repo
Step 2: The CLI downloads the requested template (tutorial, blank, tabs, sidemenu)
Step 3: The CLI creates a folder called like your project name (hello-world) and unzips the content of both downloaded templates inside.
Step 4: The CLI runs npm install inside the newly created folder

So you can do all these steps without the CLI by downloading the app-base project and then you can choose your template and copy the content of them into one folder.

1 Like

Got it, it worked. But when i run ionic serve it keeps getting

C:\asfdaf\myApp>ionic serve
Dependency missing for @ionic/cli-plugin-ionic-angular:

  [ERROR]: Cannot find module 'C:\asfdaf\myApp\node_modules\@ionic\cli-plugin-ionic-angular'

Go back to Ionic CLI 2.2.3, the beta is not made for normal development and still quite buggy.

Yes because you run CLI 3.0 Beta. Just run inside your project.

$ npm install --save-dev @ionic/cli-plugin-cordova @ionic/cli-plugin-ionic-angular

Did, and did the

$ npm install --save-dev @ionic/cli-plugin-proxy

too,

but it gives me now another error:

C:\asfdaf\myApp>ionic
TypeError: cli_utils_1.load is not a function
    at Object.<anonymous> (C:\asfdaf\myApp\node_modules\@ionic\cli-plugin-proxy\dist\index.js:5:32)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at C:\Users\MyUser\AppData\Roaming\npm\node_modules\ionic\node_modules\@ionic\cli-utils\dist\lib\plugins.js:110:17
    at Generator.next (<anonymous>)

Have you installed npm install --save-dev @ionic/cli-plugin-proxy inside your project?

Yes, here, what i did:

C:\Users\weslley.rocha\Documents\asfdaf\myApp>ionic serve
Dependency missing for @ionic/cli-plugin-proxy:

  [ERROR]: Cannot find module 'C:\Users\weslley.rocha\Documents\asfdaf\myApp\node_modules\@ionic\cli-plugin-proxy'

C:\Users\weslley.rocha\Documents\asfdaf\myApp>npm install --save-dev @ionic/cli-plugin-proxy

> spawn-sync@1.0.15 postinstall C:\Users\weslley.rocha\Documents\asfdaf\myApp\node_modules\spawn-sync
> node postinstall

ionic-app-base@0.0.0 C:\Users\weslley.rocha\Documents\asfdaf\myApp
+-- UNMET PEER DEPENDENCY @ionic/app-scripts@1.3.0
`-- @ionic/cli-plugin-proxy@0.0.1-alpha.c9d454fd
  +-- @ionic/cli-utils@0.0.9
  | +-- cross-spawn@4.0.2
  | +-- inquirer@1.2.3
  | | +-- cli-cursor@1.0.2
  | | | `-- restore-cursor@1.0.1
  | | |   +-- exit-hook@1.1.1
  | | |   `-- onetime@1.1.0
  | | +-- external-editor@1.1.1
  | | | +-- spawn-sync@1.0.15
  | | | | +-- concat-stream@1.6.0
  | | | | | +-- readable-stream@2.2.9
  | | | | | | +-- isarray@1.0.0
  | | | | | | `-- string_decoder@1.0.0
  | | | | | `-- typedarray@0.0.6
  | | | | `-- os-shim@0.1.3
  | | | `-- tmp@0.0.29
  | | +-- figures@1.7.0
  | | `-- mute-stream@0.0.6
  | `-- superagent@2.3.0
  |   +-- form-data@1.0.0-rc4
  |   | `-- async@1.5.2
  |   `-- readable-stream@2.2.9
  |     +-- isarray@1.0.0
  |     `-- string_decoder@1.0.0
  `-- superagent-proxy@1.0.2
    `-- proxy-agent@2.0.0
      +-- agent-base@2.0.1
      | `-- semver@5.0.3
      +-- http-proxy-agent@1.0.0
      +-- https-proxy-agent@1.0.0
      +-- lru-cache@2.6.5
      +-- pac-proxy-agent@1.0.0
      | +-- get-uri@1.1.0
      | | +-- data-uri-to-buffer@0.0.4
      | | +-- file-uri-to-path@0.0.2
      | | +-- ftp@0.3.10
      | | | +-- readable-stream@1.1.14
      | | | `-- xregexp@2.0.0
      | | `-- readable-stream@2.2.9
      | |   +-- isarray@1.0.0
      | |   `-- string_decoder@1.0.0
      | +-- pac-resolver@1.2.6
      | | +-- co@3.0.6
      | | +-- degenerator@1.0.4
      | | | +-- escodegen@1.8.1
      | | | | +-- esprima@2.7.3
      | | | | +-- estraverse@1.9.3
      | | | | +-- optionator@0.8.2
      | | | | | +-- deep-is@0.1.3
      | | | | | +-- fast-levenshtein@2.0.6
      | | | | | +-- levn@0.3.0
      | | | | | +-- prelude-ls@1.1.2
      | | | | | +-- type-check@0.3.2
      | | | | | `-- wordwrap@1.0.0
      | | | | `-- source-map@0.2.0
      | | | `-- esprima@3.1.3
      | | +-- netmask@1.0.6
      | | +-- regenerator@0.8.46
      | | | +-- commoner@0.10.8
      | | | | +-- detective@4.5.0
      | | | | | +-- acorn@4.0.11
      | | | | | `-- defined@1.0.0
      | | | | +-- glob@5.0.15
      | | | | +-- iconv-lite@0.4.16
      | | | | +-- q@1.5.0
      | | | | `-- recast@0.11.23
      | | | |   +-- ast-types@0.9.6
      | | | |   `-- esprima@3.1.3
      | | | +-- defs@1.1.1
      | | | | +-- alter@0.2.0
      | | | | | `-- stable@0.1.6
      | | | | +-- ast-traverse@0.1.1
      | | | | +-- breakable@1.0.0
      | | | | +-- esprima-fb@15001.1001.0-dev-harmony-fb
      | | | | +-- simple-fmt@0.1.0
      | | | | +-- simple-is@0.2.0
      | | | | +-- stringmap@0.2.2
      | | | | +-- stringset@0.2.1
      | | | | +-- tryor@0.1.2
      | | | | `-- yargs@3.27.0
      | | | |   +-- camelcase@1.2.1
      | | | |   +-- cliui@2.1.0
      | | | |   | `-- wordwrap@0.0.2
      | | | |   `-- window-size@0.1.4
      | | | +-- esprima-fb@15001.1001.0-dev-harmony-fb
      | | | +-- recast@0.10.33
      | | | | `-- ast-types@0.8.12
      | | | `-- regenerator-runtime@0.9.6
      | | `-- thunkify@2.1.2
      | `-- stream-to-buffer@0.1.0
      |   `-- stream-to@0.2.2
      `-- socks-proxy-agent@2.0.0
        `-- socks@1.1.10
          +-- ip@1.1.5
          `-- smart-buffer@1.1.15

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win
32","arch":"x64"})
npm WARN @ionic/cli-plugin-ionic-angular@0.0.6 requires a peer of @ionic/app-scripts@^1.3.1 but none was installed.

But then:

C:\Users\weslley.rocha\Documents\asfdaf\myApp>ionic serve
TypeError: cli_utils_1.load is not a function
    at Object.<anonymous> (C:\Users\weslley.rocha\Documents\asfdaf\myApp\node_modules\@ionic\cli-plugin-proxy\dist\index.js:5:32)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at C:\Users\weslley.rocha\AppData\Roaming\npm\node_modules\ionic\node_modules\@ionic\cli-utils\dist\lib\plugins.js:110:17
    at Generator.next (<anonymous>)

update your app-scripts to 1.3.4 as you can read in this error log: npm WARN @ionic/cli-plugin-ionic-angular@0.0.6 requires a peer of @ionic/app-scripts@^1.3.1 but none was installed.

run npm install --save-dev @ionic/app-scripts@latest

Tried:

C:\Users\weslley.rocha\Documents\asfdaf\myApp>npm install --save-dev @ionic/app-scripts@latest
ionic-app-base@0.0.0 C:\Users\weslley.rocha\Documents\asfdaf\myApp
`-- @ionic/app-scripts@1.3.4
  `-- uglify-js@2.8.22

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win
32","arch":"x64"})

But the error continues:

C:\Users\weslley.rocha\Documents\asfdaf\myApp>ionic serve
TypeError: cli_utils_1.load is not a function
    at Object.<anonymous> (C:\Users\weslley.rocha\Documents\asfdaf\myApp\node_modules\@ionic\cli-plugin-proxy\dist\index.js:5:32)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at C:\Users\weslley.rocha\AppData\Roaming\npm\node_modules\ionic\node_modules\@ionic\cli-utils\dist\lib\plugins.js:110:17
    at Generator.next (<anonymous>)

Ok then you should go back to the stable CLI version.

But what about the proxy problem? :confused:

You could just switch between CLI versions when you need a proxy and when you need stable development. Or you find a way to proxy the 2.2.3 CLI.

1 Like

I can see you have an error with ionic serve. SO maybe there is another problem. Can you post your package.json, please?

I switched to stable version of ionic, and still not connecting with ionic io init gives me this:

C:\Users\weslley.rocha\Documents\asfdaf\myApp>ionic io init
Initializing app with ionic.io....
An error occurred initializing the app: Error: tunneling socket could not be established, cause=getaddrinfo ENOTFOUND 3140 3140:80

But anyway here is my package.json

{
  "name": "ionic-hello-world",
  "version": "0.0.0",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "4.0.2",
    "@angular/compiler": "4.0.2",
    "@angular/compiler-cli": "4.0.2",
    "@angular/core": "4.0.2",
    "@angular/forms": "4.0.2",
    "@angular/http": "4.0.2",
    "@angular/platform-browser": "4.0.2",
    "@angular/platform-browser-dynamic": "4.0.2",
    "@ionic-native/core": "3.4.2",
    "@ionic-native/splash-screen": "3.4.2",
    "@ionic-native/status-bar": "3.4.2",
    "@ionic/cloud-angular": "^0.12.0",
    "@ionic/storage": "2.0.1",
    "ionic-angular": "3.1.0",
    "ionicons": "3.0.0",
    "rxjs": "5.1.1",
    "sw-toolbox": "3.4.0",
    "zone.js": "^0.8.5"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.3.5",
    "typescript": "^2.2.2"
  },
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-statusbar",
    "cordova-plugin-device",
    "cordova-plugin-console",
    "ionic-plugin-keyboard",
    "cordova-plugin-splashscreen"
  ],
  "cordovaPlatforms": [],
  "description": "MyApp: An Ionic project"
}

Hi do you know where and how to set environment variables?