Main.js, main.css giving 404 Not Found error randomly - RC0

Sometimes main.js and main.css is giving 404 error, so app won’t start…
without any changes if I serve again it’s working fine, this happening randomly.

Failed to load resource: the server responded with a status of 404 (Not Found)

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

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

tag_assistant_compiled.js:117 GET http://localhost:8100/build/main.js 404 (Not Found)

Please check your terminal. There may be errors that are getting printed out there.

No there is no any error in terminal, it’s happen randomly… I notice following things

  1. If I run serve command again without any changes it’s works fine, and sometime it’s don’t then I have to quite server and try again 2-3 times without any changes then it’s start working again.

  2. while server sometime it’s giving 404 error in browser console for main.js and main.css

  3. browser is not being refresh many times, I have to refresh manually from terminal.,

  4. sometimes I am getting following error
    FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

    npm

    ERR!
    Windows_NT 10.0.14393

    npm
    ERR!
    argv “C:\Program Files\nodejs\node.exe” “C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js” “run” “watch”

    npm
    ERR! node v6.2.0

    npm
    ERR! npm
    v3.8.9
    npm ERR!
    code ELIFECYCLE
    npm
    ERR! ionic-hello-world@ watch: ionic-app-scripts watch
    npm
    ERR! Exit status 3

    npm ERR!

    npm ERR!
    Failed at the ionic-hello-world@ watch script ‘ionic-app-scripts watch’.
    npm ERR!
    Make sure you have the latest version of node.js and npm installed.
    npm
    ERR! If you do, this is most likely a problem with the ionic-hello-world package,
    npm
    ERR! not with npm itself.
    npm
    ERR! Tell the author that this fails on your system:

    npm ERR! ionic-app-scripts watch

    npm ERR!
    You can get information on how to open an issue for this project with:
    npm ERR!
    npm bugs ionic-hello-world
    npm ERR!
    Or if that isn’t available, you can get their info via:
    npm
    ERR! npm owner ls ionic-hello-world
    npm
    ERR! There is likely additional logging output above.

    npm ERR! Please include the following file with any support request:
    npm ERR!
    H:\xampp\htdocs\MyAppIO2RC0\MyApp\npm-debug.log

Following is npm-debug.log

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory



npm

ERR!
 Windows_NT 10.0.14393

npm
 ERR!
argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "watch"

npm
 ERR! node v6.2.0

npm
ERR! npm
 v3.8.9
npm ERR!
code ELIFECYCLE
npm
ERR! ionic-hello-world@ watch: `ionic-app-scripts watch`
npm
 ERR! Exit status 3

npm ERR!

npm ERR!
 Failed at the ionic-hello-world@ watch script 'ionic-app-scripts watch'.
npm ERR!
 Make sure you have the latest version of node.js and npm installed.
npm
ERR! If you do, this is most likely a problem with the ionic-hello-world package,
npm
ERR! not with npm itself.
npm
 ERR! Tell the author that this fails on your system:

npm ERR!     ionic-app-scripts watch

npm ERR!
 You can get information on how to open an issue for this project with:
npm ERR!
     npm bugs ionic-hello-world
npm ERR!
 Or if that isn't available, you can get their info via:
npm
ERR!     npm owner ls ionic-hello-world
npm
ERR! There is likely additional logging output above.



npm ERR! Please include the following file with any support request:
npm ERR!
     H:\xampp\htdocs\MyAppIO2RC0\MyApp\npm-debug.log

If above thing happen I have to quite server and run serve again then again it’s start working

I never face such issue with Beta 11 this only happening in RC0

@jigsaxis Did you find any solution to this? The ionic serve works fine and generates main.js but ionic build or ionic run does not…

No sitll I didn’t get any solution, after updating RC0 getting lots of issue :frowning:

build and run not working, but run fine in browser…

@jigsaxis The build is fine I check that if there are any errors in the code the the ionic-server will run any way…but when you build or run the linter will not allow to create the main.js…So the problem is in the code and not with ionic CLI

same error with rc0.
ionic serve works well in browser, but build is not creating main.js or main.css

To reiterate what @mhartington said, make sure to check your build console carefully. There are some libraries and code constructs that are treated very differently by the dev and prod build systems, and it is very possible that you are doing something that is accepted by dev mode but rejected by prod.

Have the same problem…404 errors out of sudden. When I have a 404 all builds also fail (same cli error as jigsaxis). But normally it doesn’t go away. I have to manually copy my code to a new project, to make it work again. Slows down productivity a lot :confused:

Having the same issue on Windows 10. > ionic build always builds main.js, but > ionic serve deletes and then doesn’t re-create it. Clean console output. Really slowing me down…

1 Like

I’m getting these errors while going through this great tut.
I get main.js and main.css not found in the console while running ionic serve.
I’m on Mac OSX 10.10.5/Chrome 53 using the latest Ionic 2.
The sample code runs without these errors. However, going through the tutorial step by step, after step 3, running ionic serve the app is broken with those errors in the console.

I use

Ionic Framework Version: 2.0.0-rc.1
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.0.0-beta.20

This also happened to me. I figured it out that it’s when I import my own npm package via import {myStuff} from 'myStuffJs'; it silently shows similar error at browser’s console but not during ionic serve.

But after I changed code back to normal way using <script src='myStuffJs.min.js> and in.tssource file, I dodeclare var myStuff: any;`, it has no problem.

I got same problem.
Ionic serve was working fine.
15 minutes later, try to run ionic serve again and got the message on console:

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

Upgrade to RC1, in rc1 it’s working fine

I’m still facing the same problem , how did you upgrade it ??

Thanks

Check following link fo upgrade
http://blog.ionic.io/ionic-2-rc-weekend-updates/

Did you resolve issue? I have same problem.

I have the same issue in Ionic 3 after I install cordova-plugin-market. The ‘run’ command succeeds but the build folder only contains two files. I’ve logged this as the following bug:

BUILD SUCCESSFUL

Total time: 25.622 secs

Built the following apk(s): 
..../platforms/android/build/outputs/apk/android-debug.apk

ANDROID_HOME=~/Library/Android/sdk

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home

Skipping build...

Built the following apk(s): 
..../platforms/android/build/outputs/apk/android-debug.apk

Using apk: ..../platforms/android/build/outputs/apk/android-debug.apk

Package name: com.blah.blah

LAUNCH SUCCESS

The build folder is virtually empty

/www/build
    polyfills.js
    sw-toolbox.js

If I remove cordova-plugin-market, the /www/build looks correct:

/www/build
    main.css
    main.css.map
    main.js
    main.js.map
    polyfills.js
    sw-toolbox.js

Info:

Cordova CLI: 6.5.0 
Ionic CLI Version: 2.2.3
Ionic App Lib Version: 2.2.1
ios-deploy version: 1.9.1 
ios-sim version: 5.0.13 
OS: OS X El Capitan
Node Version: v6.10.0
Xcode version: Xcode 8.2.1 Build version 8C1002

hai everyone
In my project main.css file is missing
can u tell me how to resolve it.
i an using ionic 3

My Error
Failed to load resource: the server responded with a status of 404 (Not Found)

I attached my error screenshot below

I have the same problem, did you solve?