Problems with public directory when deploying Node.js app with Heroku

╄→гoц情女王★ 提交于 2019-12-11 18:07:30

问题


I've been working on an app which will feature a Timelinejs (open source js library) element on the client side. I copied the Timelinejs library into my public/javascripts/ directory of my app. Then I linked it in my html header. When I serve my app up locally everything works fine with the timeline. However, I noticed that when I deployed my app to Heroku it wasn't loading my timeline. Using chrome js console I discovered that it didn't find my files in the public/Javascripts/Timelinejs folder. Using the Heroku run bash command I discovered that none of my Timelinejs files were present in the file structure, although an empty Timelinejs directory was present. Is there any command or configuration I need to specify to get these files to my Heroku deployment?


回答1:


Heroku has a readonly file system. The directory where you can write are ./tmp or ./log. You can't write inside the public folder. That's because of how they manage their dynos and the way to scale them. If you want to store something, use the ./tmp or, recommended, a s3 bucket. (as I presume 'tmp' stands for 'temporary' :D)

More info here: https://devcenter.heroku.com/articles/read-only-filesystem



来源:https://stackoverflow.com/questions/19787819/problems-with-public-directory-when-deploying-node-js-app-with-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!