TREX_SON
TREX_SON

Reputation: 45

Heroku has issues with js and css

I'm totally new to deploying node websites and i swear i never knew it was so tough i think, to do, i am using Heroku, i wish could use something better, but the problem i have is, the site works on my local server, why am i getting error after error with this Heroku cli. After i deploy, the index page is off because the css and javascript never worked, and the other links dont work, only the index works. I have seen a couple of solutions online but th estage i am right now, there see,s to be none online. Heres the error Heroku shows me in Logs:

2019-11-27T22:47:18.864670+00:00 heroku[router]: at=info method=GET path="/" host=mysterious-inlet-01420.herokuapp.com request_id=ec247278-53f7-42d7-a562-699f102bda83 fwd="73.8.104.52" dyno=web.1 connect=1ms service=18ms status=404 bytes=412 protocol=https
2019-11-27T22:47:18.864800+00:00 app[web.1]: Error: ENOENT: no such file or directory, stat '/app/assets/bootstrap/js/bootstrap.min.js'
2019-11-27T22:47:22.312692+00:00 app[web.1]: Error: ENOENT: no such file or directory, stat '/app/assets/bootstrap/js/bootstrap.min.js'
2019-11-27T22:47:22.313735+00:00 heroku[router]: at=info method=GET path="/" host=mysterious-inlet-01420.herokuapp.com request_id=fc2a26bb-8fdd-4eaf-bd3f-81808ad438d2 fwd="73.8.104.52" dyno=web.1 connect=1ms service=3ms status=404 bytes=412
2019-11-27T22:48:56.275049+00:00 heroku[web.1]: Restarting
2019-11-27T22:48:56.292904+00:00 heroku[web.1]: State changed from up to starting
2019-11-27T22:48:56.000000+00:00 app[api]: Build succeeded
2019-11-27T22:48:57.256875+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2019-11-27T22:48:57.335477+00:00 heroku[web.1]: Process exited with status 143
2019-11-27T22:49:01.596770+00:00 heroku[web.1]: Starting process with command `node app.js`
2019-11-27T22:49:04.690575+00:00 app[web.1]: Server is up and running on port number 36856
2019-11-27T22:49:06.029401+00:00 heroku[web.1]: State changed from starting to up
2019-11-27T22:49:10.502475+00:00 heroku[router]: at=info method=GET path="/" host=mysterious-inlet-01420.herokuapp.com request_id=0fe4b625-8759-41fb-857a-3b155051c664 fwd="73.8.104.52" dyno=web.1 connect=1ms service=22ms status=200 bytes=65133 protocol=https
2019-11-27T22:49:10.608984+00:00 heroku[router]: at=info method=GET path="/assets/images/mfm-logo-png-122x122.png" host=mysterious-inlet-01420.herokuapp.com request_id=a98b035b-4cd3-4065-8019-3d9ad1f190c8 fwd="73.8.104.52" dyno=web.1 connect=1ms service=5ms status=404 bytes=453 protocol=https
2019-11-27T22:49:10.702991+00:00 heroku[router]: at=info method=GET path="/assets/images/019.jpg" host=mysterious-inlet-01420.herokuapp.com request_id=c5e1353e-15f4-477e-b392-d9cce88f424e fwd="73.8.104.52" dyno=web.1 connect=1ms service=3ms status=404 bytes=436 protocol=https
2019-11-27T22:49:10.807554+00:00 heroku[router]: at=info method=GET path="/assets/popper/popper.min.js" host=mysterious-inlet-01420.herokuapp.com request_id=4ebedaea-5639-480e-982f-3d98b1aefb42 fwd="73.8.104.52" dyno=web.1 connect=1ms service=4ms status=404 bytes=442 protocol=https
2019-11-27T22:49:10.805252+00:00 heroku[router]: at=info method=GET path="/assets/images/02.jpg" host=mysterious-inlet-01420.herokuapp.com request_id=81652694-340b-430c-84d2-f9256448fbcb fwd="73.8.104.52" dyno=web.1 connect=2ms service=3ms status=404 bytes=435 protocol=https
2019-11-27T22:49:10.787920+00:00 heroku[router]: at=info method=GET path="/assets/index-additional/event-cards.js" host=mysterious-inlet-01420.herokuapp.com request_id=18f4b82e-28f5-42d6-a239-833f142d62d5 fwd="73.8.104.52" dyno=web.1 connect=1ms service=2ms status=404 bytes=453 protocol=https
2019-11-27T22:49:10.803912+00:00 heroku[router]: at=info method=GET path="/assets/index-additional/church-slider.js" host=mysterious-inlet-01420.herokuapp.com request_id=b2715c95-10de-4e65-80e7-3d1d80a44123 fwd="73.8.104.52" dyno=web.1 connect=2ms service=3ms status=404 bytes=455 protocol=https...

Anybody with any solution to this, or another platform that would allow me to deploy seamlessly without much changes My Folder tree is like:

-mfm web
--Views
---assets
    **js files

Upvotes: 0

Views: 71

Answers (1)

Aymen Bou
Aymen Bou

Reputation: 1109

Looks to me like you haven't told the app to include assets created within your Views directory.

You want to join the path of your assets to the asset tree using:

yourappname.use(express.static(path.join(__dirname, 'Views')))

Upvotes: 1

Related Questions