ionic-cli icon indicating copy to clipboard operation
ionic-cli copied to clipboard

Ionic serve dont serve the app on the browser

Open leonardocoutinho opened this issue 9 years ago • 19 comments

Hello. Ionic serve command gives an error: TypeError: Cannot read property 'launchBrowser' of undefined. I cant use my app on the browser or device.

My Ionic Info

@ionic/cli-plugin-cordova       : 1.6.2
@ionic/cli-plugin-ionic-angular : 1.4.1
@ionic/cli-utils                : 1.7.0
ionic (Ionic CLI)               : 3.7.0

global packages:

Cordova CLI : 7.0.1 

local packages:

@ionic/app-scripts : 2.1.3
Cordova Platforms  : android 6.2.3
Ionic Framework    : ionic-angular 3.6.0

System:

Node : v6.10.3
OS   : Linux 4.4
npm  : 3.10.10 

leonardocoutinho avatar Aug 08 '17 12:08 leonardocoutinho

What is the exact command you are executing?

janpio avatar Aug 08 '17 12:08 janpio

@janpio the command is "ionic serve" inside my project

leonardocoutinho avatar Aug 08 '17 14:08 leonardocoutinho

Please run ionic serve --verbose and post the whole output.

janpio avatar Aug 08 '17 14:08 janpio

@janpio the output:

[DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: '/home/leonardo/3ionicprojects/cdm_admin', local: true, binPath:
        '/usr/local/lib/node_modules/ionic/bin/ionic', libPath:
        '/home/leonardo/3ionicprojects/cdm_admin/node_modules/ionic/dist/index.js' }
[DEBUG] Loading local plugin @ionic/cli-plugin-proxy
[DEBUG] Throwing PLUGIN_NOT_INSTALLED for local @ionic/cli-plugin-proxy
[DEBUG] Loading local plugin @ionic/cli-plugin-cordova
[DEBUG] Loading local plugin @ionic/cli-plugin-ionic-angular
[DEBUG] Getting plugin info for ionic
[DEBUG] Checking for latest plugin version of ionic@latest.
[DEBUG] Getting plugin info for @ionic/cli-plugin-cordova
[DEBUG] Checking for latest plugin version of @ionic/cli-plugin-cordova@latest.
[DEBUG] Getting plugin info for @ionic/cli-plugin-ionic-angular
[DEBUG] Checking for latest plugin version of @ionic/cli-plugin-ionic-angular@latest.
[DEBUG] Daemon found (pid: 3977)
[INFO] Starting app-scripts server: --log-level debug --port 8100 --p 8100 --livereload-port 35729 --r 35729 --address
       localhost - Ctrl+C to cancel
TypeError: Cannot read property 'launchBrowser' of undefined
[DEBUG] TypeError: Cannot read property 'launchBrowser' of undefined
        at onReady (/home/leonardo/3ionicprojects/cdm_admin/node_modules/@ionic/app-scripts/dist/serve.js:70:15)
        at /home/leonardo/3ionicprojects/cdm_admin/node_modules/@ionic/app-scripts/dist/serve.js:63:13
        at process._tickCallback (internal/process/next_tick.js:109:7)
leonardo@coutinho-pc:~/3ionicprojects/cdm_admin$  ```

leonardocoutinho avatar Aug 08 '17 14:08 leonardocoutinho

(Add ```(newline) before and (newline)``` after to format better)

Thanks, this will help the devs.

janpio avatar Aug 08 '17 14:08 janpio

@janpio thanks, any idea ?

leonardocoutinho avatar Aug 08 '17 14:08 leonardocoutinho

No. Try adding the -b parameter to not launch a browser, but this is just because it has a similar name to your error message :p

janpio avatar Aug 08 '17 15:08 janpio

The same error appear, but i think the problem is with app-scripts. But i dont know the solution :'(

leonardocoutinho avatar Aug 08 '17 15:08 leonardocoutinho

You might want to create an issue there (https://github.com/ionic-team/ionic-app-scripts/issues) as well, and link to this one.

janpio avatar Aug 08 '17 15:08 janpio

@leonardocoutinho try npm run ionic:serve. I've seen many people asking about ionic serve not working, it may be something with the new 3.7.0 CLI because app-scripts serve via npm run works fine. But try this command and see if it works for you.

synga avatar Aug 09 '17 17:08 synga

Hello @synga i just downgrade the ionic version from 3.6.0 to 3.5.0, and works fine. In the future if i had the same error i will try your solution. Thanks.

leonardocoutinho avatar Aug 10 '17 09:08 leonardocoutinho

I get the same issue with upgrading ionic version to 3.7.0, but works fine with 3.6.0.

[DEBUG] CLI flags: { interactive: true, confirm: false } [DEBUG] { cwd: '/Users/Tony/Documents/ion2', local: true, binPath: '/usr/local/lib/node_modules/ionic/bin/ionic', libPath: '/Users/Tony/Documents/Nimble/01workspace/ion2/node_modules/ionic/dist/index.js' } [DEBUG] Loading local plugin @ionic/cli-plugin-proxy [DEBUG] Throwing PLUGIN_NOT_INSTALLED for local @ionic/cli-plugin-proxy [DEBUG] Loading local plugin @ionic/cli-plugin-cordova [DEBUG] Loading local plugin @ionic/cli-plugin-ionic-angular [DEBUG] New daemon pid: 44719 [DEBUG] Getting plugin info for ionic [DEBUG] Checking for latest plugin version of ionic@latest. [DEBUG] Getting plugin info for @ionic/cli-plugin-cordova [DEBUG] Checking for latest plugin version of @ionic/cli-plugin-cordova@latest. [DEBUG] Getting plugin info for @ionic/cli-plugin-ionic-angular [DEBUG] Checking for latest plugin version of @ionic/cli-plugin-ionic-angular@latest. [INFO] Starting app-scripts server: --log-level debug --port 8100 --p 8100 --livereload-port 35729 --r 35729 --address localhost - Ctrl+C to cancel TypeError: Cannot read property 'launchBrowser' of undefined [DEBUG] TypeError: Cannot read property 'launchBrowser' of undefined at onReady (/Users/Tony/Documents/Nimble/01workspace/ion2/node_modules/@ionic/app-scripts/dist/serve.js:70:15) at /Users/Tony/Documents/Nimble/01workspace/ion2/node_modules/@ionic/app-scripts/dist/serve.js:63:13 workaround:

  1. Trying the command @synga post. npm run ionic:serve works good.
  2. Or you can try to downgrade ion-cli verion from 3.7.0 to 3.6.0 by this command npm install --save-dev --save-exact [email protected]

twltony avatar Aug 14 '17 03:08 twltony

Hi all, this was a bug introduced in CLI 3.7 that I've fixed with 3.8 (just released). Please give it a try and let me know if you have any issues! Sorry about that!

imhoffd avatar Aug 14 '17 23:08 imhoffd

@dwieeb updated and it's all good, thanks.

synga avatar Aug 15 '17 16:08 synga

Hi I have just updated to 3.8.1 but this doesn't fix the problem node - 8.2.1 npm 5.3.0 ionic 3.8.1 Ubuntu 14.04 LTS

parvanova avatar Aug 15 '17 20:08 parvanova

@parvanova I believe the commit above ^ will fix your issue, but I also believe there is an underlying error you're getting that's not surfacing.

imhoffd avatar Aug 15 '17 21:08 imhoffd

sorry for the dummy question but how do I apply this commit. I don't even have such file in node_modules/@ionic/app_scripts And if I have an underlying error how do I get it?

Thanks

parvanova avatar Aug 15 '17 21:08 parvanova

@parvanova If you don't have that folder, then your error is different.

imhoffd avatar Aug 15 '17 22:08 imhoffd

@leonardocoutinho Thanks man, It works for me.

jayeshdhage07 avatar Apr 09 '18 05:04 jayeshdhage07