1

I have recently been building an Angular2 starter kit for my own use, using various bits and pieces found in tutorials and SO. I now have gulp tasks to bundle the app for production but it won't work without running it through a server, node in this case.

Here is the repo: https://github.com/LGLabGreg/lg-angular2

Basically running gulp dist will bundle the app fine in dist/ folder, but clicking the index.html in that folder doesn't work, the app is stuck on "Loading...". If I serve it with node it works.

Thanks.

2
  • What does your node file (usually app.js OR bin/www) look like? You have to start the node server and navigate to the correct localhost port. Commented Nov 4, 2016 at 16:02
  • 1
    Thanks Jeremy, it does work with node, but I would like it to work "standalone" by just opening the index.html in a browser or uploading it via ftp. Commented Nov 4, 2016 at 16:26

1 Answer 1

2

That's because when you are serving it from node the baseUrl is set correct /, but when you just click on index.html the baseUrl is set to / which will probably be C:\ (file://). Resulting in the browser trying to obtain all resource from file://. Check your browser console for errors

Sooooo... that's a pickle

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks Pierre, that was it. Oddly enough I wasn't getting console errors locally which would have been helpful and I didn't actually check the console after I uploaded via ftp. So if uploaded to the root of a server the default base url / will work, just needs to be adjusted if the app is in a folder, and use a server locally. I upvoted your answer but I don't have enough rep :(
@PierreDuc how would I fix it in this scenario?
Use a web server, or set the base URL to the folder of your index.html location

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.