ionic-cli: ionic serve/build is not building main.js nor outputting any errors

From @ajmesa9891 on December 6, 2016 0:43

Ionic version: (check one with “x”) [ ] 1.x [x] 2.x

I’m submitting a … (check one with “x”) [x] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:

When working on a project running ionic serve runs into the issue below in the browser

http://localhost:8100/build/main.js Failed to load resource: the server responded with a status of 404 (Not Found)

And I do not see any errors in the logs terminal.

When running ionic build

[19:41:14]  uglifyjs failed: ENOENT: no such file or directory, open
            '/Users/alejandrom/cajitas-cooks-app/www/build/main.js'
[19:41:14]  ionic-app-script task: "build"
[19:41:14]  Error: ENOENT: no such file or directory, open '/Users/alejandrom/cajitas-cooks-app/www/build/main.js'

I also ran ionic-app-scripts transpile; it finishes without outputting any errors in the terminal

Expected behavior:

I would expect for the site to be served and the app to be built. Or to see errors explaining why the build failed.

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.3
Ionic CLI Version: 2.1.14
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.46
ios-deploy version: 1.9.0
ios-sim version: 5.0.9
OS: OS X El Capitan
Node Version: v6.7.0
Xcode version: Xcode 8.1 Build version 8B62

Copied from original issue: driftyco/ionic#9505

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 16 (4 by maintainers)

Most upvoted comments

Also seeing this issue when typescript has an error. A way to reproduce:

  1. import something that doesn’t exist
  2. ionic serve
  3. save a file to trigger a rebuild

Notice something along the lines of this in the output:

[17:52:49]  transpile update started ...
[17:52:49]  transpile update finished in 29 ms

Output does not contain any of the initial typescript errors. Hrmmm… Bothersome.

Go modify https://github.com/ionic-team/ionic-app-scripts/blob/master/src/transpile.ts#L179 to always return false.

  1. restart ionic serve
  2. save a file to trigger a rebuild

Notice the typescript failure in the rebuild output:

[18:10:16]  transpile started ...
[18:10:16]  typescript: src/pages/home/home.ts, line: 4
            File '/Users/norm/src/models/device.ts' is not a module.

       L3:  import { ConnectedDevicesProvider } from '../../providers/connected-devices/connected-devices';
       L4:  import { DeviceModel } from '../../models/device';

It seems like some logic is incorrect in transpile.ts canRunTranspileUpdate() and masking typescript errors on a update vs a build. Looking like this issue is very much real.

i have the problem that ionic serve does only show Typescript errors on first build. After that when the watch triggers, it does not show any errors no more but just says “Build finished”. Completely stupid and unusable…

Just in case some people still land here with this type of error, I found out that you can identify import errors from barrels (index.ts) during transpile by removing declare module '*'; from src/declarations.d.ts.

See the declarations.d.ts file comments for explanations about what this wildcard module is about.

The following error do not output when declare module '*'; is present, which leads to the main.js not being built, and the app displaying nothing, with a 404 on www/build/main.js.

In this case, the import path export * from './facebook-credentials'; was incorrect or the file did not exist.

C:\work\[myApp]> ionic serve
[INFO] Starting app-scripts server: --address 0.0.0.0 --port 8100 --livereload-port 35729 -
       Ctrl+C to cancel
[21:08:50]  watch started ...
[21:08:50]  build dev started ...
[21:08:50]  clean started ...
[21:08:50]  clean finished in 19 ms
[21:08:50]  copy started ...
[21:08:50]  transpile started ...
[21:09:02]  typescript: C:/work/[myApp]/src/models/auth/index.ts, line: 2
Cannot find module './facebook-credentials'.
       L1:  export * from './base-credential';
       L2:  export * from './facebook-credentials';
       L3:  export * from './login-credentials';

You obviously need to restore declare module '*'; in src/declarations.d.ts in case your app use third party libs that do not have definition files (cases when you need to declare things like declare var xxxxx: any; on top of class). I don’t know if this is mandatory regarding the ionic or angular framework.

This error happens often when you refactor/clean your code too hard at once

+1 Facing the same issue