Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
203 views
in Technique[技术] by (71.8m points)

javascript - Heroku的js和css有问题(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.(我对部署节点网站是完全陌生的,我发誓我从来不知道这是如此困难,我想这样做,我正在使用Heroku,希望可以使用更好的东西,但是我遇到的问题是,该网站可以在本地运行服务器,为什么我在使用此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.(部署后,索引页面关闭,因为CSS和javascript从未起作用,其他链接不起作用,只有索引起作用。) 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:(这是Heroku在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
  ask by TREX_SON translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Looks to me like you haven't told the app to include assets created within your Views directory.(在我看来,您尚未告诉应用程序将在Views目录中创建的资产包括在内。)

You want to join the path of your assets to the asset tree using:(您想要使用以下方法将资产的路径加入资产树:)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...