Coder Social home page Coder Social logo

Comments (14)

MarshallOfSound avatar MarshallOfSound commented on May 18, 2024 1

@ahadcove Your JS files must be inside a directory (not just sitting in the top level of your app). I.e. If you move main.js to be somewhere like src/main.js and update your package.json accordingly the packaged version will work.

/cc @malept We should probably catch this issue ourselves

from forge.

MarshallOfSound avatar MarshallOfSound commented on May 18, 2024
  • Does it work with a simple electron-forge start
  • How are you requiring main.js, is it your entry point?

from forge.

ahadcove avatar ahadcove commented on May 18, 2024

Well when I use START the same thing is happening when I was using electron-packager: A static index.html with the loading text that I have when starting up my electron app for the first time.
It suppose to route to my home as soon as it starts though as it does when I have a simple ng build.

I am requiring main.js as my entry point.

in my Package.json the main field is:

"main":"main.js"

from forge.

ahadcove avatar ahadcove commented on May 18, 2024

I switched the directories and everything and it does get past the error. I am still running into the static index.html though.

For some reason, I just can't figure out how to make my App work all packaged up

from forge.

MarshallOfSound avatar MarshallOfSound commented on May 18, 2024

@ahadcove I am not too familiar with the intricacies of Angular 2, can you explain what you mean by "static index.html". I don't quite understand the issue you are having.

from forge.

ahadcove avatar ahadcove commented on May 18, 2024

Well my original problem was that when I run my project with ng build or ng serve it works 100% all the routers and everything just works.
It was when I started trying to package up my app with electron-packager, builder, and forge where I get the routes no longer working. Instead of loading up the Index.html then immediately navigating to my home component it stays at the index.

from forge.

MarshallOfSound avatar MarshallOfSound commented on May 18, 2024

This sounds familiar from an Electron issue. I believe it is due to how in Electron your Angular app is served from a file:// url which angular routers do not like or expect.

from forge.

ahadcove avatar ahadcove commented on May 18, 2024

Hmmm That sounds like where my problem may lie, but Why would it work with ng serve and build?

from forge.

MarshallOfSound avatar MarshallOfSound commented on May 18, 2024

@ahadcove ng serve runs a localhost server I believe, so it will be served over something like http://localhost:1234

from forge.

ahadcove avatar ahadcove commented on May 18, 2024

Okay so it may have something to do with Hash Locations or something
I will dig a little deeper. I may come back to forge later when I figure this out. Thanks for everything

from forge.

MarshallOfSound avatar MarshallOfSound commented on May 18, 2024

@ahadcove FWIW this is not a -forge or -packager issue, it is purely an issue with Angular 2 in Electron in general.

This might help you out
electron/electron#6799 (comment)

It looks like you need

document.write('<base href="file://' + __dirname + '/"/>');

To use a router in Angular in Electron

from forge.

ahadcove avatar ahadcove commented on May 18, 2024

Yes, I have that in my index.html already. That is what get's routers working. I have a fully working angular 2 Electron app already, its just when I package it with anything it no longer functions how it should be

from forge.

MarshallOfSound avatar MarshallOfSound commented on May 18, 2024

Is the app public, I'm happy to dive into it and see what's going on?

from forge.

ahadcove avatar ahadcove commented on May 18, 2024

Sadly, it's not. I'm going to keep picking away at it though. I definitely like the idea of forge though so I may be back when I get this figured out. Thank you for everything

from forge.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.