`Ionic Serve` doesn't build anything

This has happened twice now. For some reason when I run the ionic serve command it doesn’t do much other than start up a local web server and the only file brought over is the index.html file. No errors in the terminal.

I’m not sure what could be causing this because it seems to occur randomly. The first time it happened I did some troubleshooting for 2 hours then gave up. Started a whole new ionic project from scratch and slowly copied over all the files one by one checking along the way to make sure the app still runs. After I had all the file completely pulled over it worked fine so I just assumed it was a random deal. But now it just randomly happened again. The only thing I did from the point between when it worked and didn’t work was push the code to a github repo. Somehow that broke it…

Any ideas on what’s going on?

ionic info:

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.19.0
    ionic (Ionic CLI) : 3.19.0

global packages:

    cordova (Cordova CLI) : 7.1.0 

local packages:

    @ionic/app-scripts : 3.1.4
    Cordova Platforms  : android 6.3.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node  : v8.9.1
    npm   : 5.6.0 
    OS    : macOS High Sierra
    Xcode : Xcode 9.2 Build version 9C40b 

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro

34 PM01 PM

This is because there are some errors in your coding.

Get Microsoft’s Visual Studio Code editor (free). It will show you which part of your typescript has errors.

This happens when there are errors in code.

Thanks for the quick reply @jamesharvey!

I’m using webstorm as my IDE. It doesn’t show any errors in the project navigator.

Also, when I run ionic serve it acts like everything is all good, with no errors in the console. Would a TS compile error not be shown in the build process for some reason as it normally does?

Ionic serve terminal output example:

Users-iMac myApp user$ ionic serve
Starting app-scripts server: --address 0.0.0.0 --port 8100 --livereload-port 35729 --dev-logger-port 53703 --nobrowser - 
Ctrl+C to cancel
[17:59:54]  watch started ... 
[17:59:54]  build dev started ... 
[17:59:54]  clean started ... 
[17:59:54]  clean finished in 1 ms 
[17:59:54]  copy started ... 
[17:59:54]  deeplinks started ... 
[17:59:54]  deeplinks finished in 57 ms 
[17:59:54]  transpile started ... 
[17:59:56]  dev server running: http://localhost:8100/ 

[OK] Development server running!
     Local: http://localhost:8100
     External: http://192.168.0.28:8100
     DevApp: myApp@8100 on Users-iMac.local

[17:59:56]  watch ready in 2.21 s 
[17:59:56]  copy finished in 2.18 s 

Try to install Visual Studio Code… it shows you angular & typescript errors automatically. It has angular 4 and 5 information inside. I think Visual Studio Code is the only code editor with this feature.

This error happened to me like 20 times and its cause was my mistake in coding.
When I correct errors, my app went back to normal.

Bullshit, Typescript errors would be shown during the build process @jamesharvey The IDE is irrelevant here.

@pfallin, run the same command with --verbose please.
Is you project generated into the www folder as it should?
Try to create a new project with ionic start, does it work there?

In which page your working. app.html or home.html

@Sujan12 I tried running the --verbose option earlier and it didn’t give me anything good. Here’s the output:

Users-iMac:myApp user$ ionic serve --verbose
[DEBUG] Reason for not using local CLI: LOCAL_CLI_NOT_FOUND
[DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: '/Users/User/Desktop/myAppFolder/myApp', local: false, binPath: 
        '/usr/local/lib/node_modules/ionic/bin/ionic', libPath: '/usr/local/lib/node_modules/ionic/dist/index.js' }
[DEBUG] Daemon found (pid: 596)
Starting app-scripts server: --address 0.0.0.0 --port 8100 --livereload-port 35729 --dev-logger-port 53703 --nobrowser - 
Ctrl+C to cancel
[14:19:53]  watch started ... 
[14:19:53]  build dev started ... 
[14:19:53]  clean started ... 
[14:19:53]  clean finished in 1 ms 
[14:19:53]  copy started ... 
[14:19:53]  deeplinks started ... 
[14:19:53]  deeplinks finished in 71 ms 
[14:19:53]  transpile started ... 
[14:19:55]  dev server running: http://localhost:8100/ 

[OK] Development server running!
     Local: http://localhost:8100
     External: http://192.168.0.28:8100
     DevApp: myApp@8100 on Users-iMac.local

[14:19:55]  watch ready in 2.36 s 
[14:19:55]  copy finished in 2.32 s 

And creating a brand new ionic project does work just fine. It also logs the same details as above. Also, theres not really anything in the www folder either.
55 PM

@tejakumar not sure what your question is referring to. I have a lot of pages in the app that worked fine before. I’ve been working on all of them but haven’t really messed with app.html though.

I figured out the issue by slowly adding pieces of my code to a new working ionic app. The issue I found was due to a simple typo that I would think would show up as a compile error during the build or in my IDE.

I had a variable in my class that I was trying to set as an empty array and ended up setting it as an invalid type because I used : instead of =. For example: items: [];.

Removing this allowed for a successful build and I now have it back up and running. Strange that the compiler didn’t catch this as an error and completely failed the build process. :thinking:

Anyway, thanks to everyone that helped me troubleshoot the issue!

Just change the @ionic/app-scripts dependency version:

"devDependencies": {
    "@ionic/app-scripts": "^3.1.1",

and run

npm install